We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: HTMLUIControl

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.


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
    BaseElement maskedEditTextBoxElement1 = htmlelements["MaskedEditTextBox1"] as
    new CustomControlBase( maskedEditTextBoxElement1, this.maskedEditBox1 );
    BaseElement buttonElement = htmlelements["Button1"] as BaseElement;
    new CustomControlBase( buttonElement, this.button1 );



Private Sub htmluiControl1_PreRenderDocument(ByVal sender As Object, ByVal e As
    Dim htmlelements As Hashtable = New Hashtable()
    htmlelements = e.Document.ElementsByUserID
    'here the base functionality of the 'this.maskedEditBox1' is implemented to the
    Dim maskedEditTextBoxElement1 As BaseElement = CType(IIf(TypeOf
    htmlelements("MaskedEditTextBox1") Is BaseElement, htmlelements("MaskedEditTextBox1"),
Nothing), BaseElement)
    Dim oTemp As CustomControlBase = New CustomControlBase(maskedEditTextBoxElement1,
    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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile