Articles in this section
Category / Section

How to create an interface between the custom control elements defined inside the HTML document and the WinForms control in the HTMLUIControl?

2 mins read

Custom controls

The custom controls defined in the HTML document are interfaced with their equivalent windows forms control with the help of the the PreRenderDocument event. The PreRenderDocument event occurs at a time when the HTML document is being loaded into the HTMLUI control, but the elements are not yet positioned.

The HTML elements are loaded into an hashtable with an equivalent id as their key. An equivalent Base class object, here BaseElement class, is defined to link the HTML elements stored in the hashtable with the help of the key associated with the element. The BaseElement is the Base class for all HTML elements. All HTML tag elements inherit this class.

The CustomControlBase implements the base functionality of the Windows forms control on the HTML tag element.

C#

private void htmluiControl1_PreRenderDocument(object sender,
Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentArgs e)
{
    Hashtable htmlelements = new Hashtable();
    htmlelements = e.Document.ElementsByUserID;
    //here the base functionality of the 'this.maskedEditBox1' is implemented to the
    'maskedEditTextBoxElement1'
    BaseElement maskedEditTextBoxElement1 = htmlelements["MaskedEditTextBox1"] as
BaseElement;
    new CustomControlBase( maskedEditTextBoxElement1, this.maskedEditBox1 );
    BaseElement buttonElement = htmlelements["Button1"] as BaseElement;
    new CustomControlBase( buttonElement, this.button1 );
}

 

VB

Private Sub htmluiControl1_PreRenderDocument(ByVal sender As Object, ByVal e As
Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentArgs)
    Dim htmlelements As Hashtable = New Hashtable()
    htmlelements = e.Document.ElementsByUserID
    'here the base functionality of the 'this.maskedEditBox1' is implemented to the
    'maskedEditTextBoxElement1'
    Dim maskedEditTextBoxElement1 As BaseElement = CType(IIf(TypeOf
    htmlelements("MaskedEditTextBox1") Is BaseElement, htmlelements("MaskedEditTextBox1"),
Nothing), BaseElement)
    Dim oTemp As CustomControlBase = New CustomControlBase(maskedEditTextBoxElement1,
    Me.maskedEditBox1)
    Dim buttonElement As BaseElement = CType(IIf(TypeOf htmlelements("Button1") Is BaseElement,
htmlelements("Button1"), Nothing), BaseElement)
    Dim oTemp As CustomControlBase = New CustomControlBase(buttonElement, Me.button1)
End Sub

 

Reference link: https://help.syncfusion.com/windowsforms/html-viewer/custom-controls

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied