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 change the characteristic of an element before it is being displayed using the prerender document event of the WinForms HTMLUIControl?

Platform: WinForms |
Control: HTMLUIControl

PrerendererDocument event

The Characteristic of an element can be easily changed in the PrerenderDocument Event of the HTMLUI control.

The Prerenderdocument event is raised when the elements in the HTML document are created in the HTMLUI control but their size and location are not calculated yet.

This event is used to change the characteristics of the element before they are positioned in the HTMLUI control.

The following snippet shows how an image reference is changed for a page in the HTMLUI at run time in the PrerenderDocument Event.


Hashtable htmlelements = new Hashtable();
this.htmluiControl1.PreRenderDocument += new Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentEventHandler(this.htmluiControl1_PreRenderDocument);
private void htmluiControl1_PreRenderDocument(object sender,PreRenderDocumentArgs e)
    this.htmlelements = e.Document.GetElementsByNameHash();
    ArrayList imgs = this.htmlelements["img"] as ArrayList;
    foreach(BaseElement elem in imgs)
        string oldValue = elem.Attributes["src"].Value;
        string newValue = e.Document.CurrentDirectory + "\\sync.jpg";
        elem.Attributes["src"].Value = oldValue.Replace(elem.Attributes["src"].Value, newValue);



Private htmlelements As Hashtable = New Hashtable()
Private Me.htmluiControl1.PreRenderDocument += New Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentEventHandler(Me.htmluiControl1 _PreRenderDocument)
Private Sub htmluiControl1_PreRenderDocument(ByVal sender As Object, ByVal e As PreRenderDocumentArgs)
    Me.htmlelements = e.Document.GetElementsByNameHash()
    Dim imgs As ArrayList = CType(IIf(TypeOf Me.htmlelements("img") Is ArrayList,  Me.htmlelements("img"), Nothing), ArrayList)
    For Each elem As BaseElement In imgs
        Dim oldValue As String = elem.Attributes("src").Value
        Dim newValue As String = e.Document.CurrentDirectory & "\sync.jpg"
        elem.Attributes("src").Value = oldValue.Replace(elem.Attributes("src").Value, newValue)
    Next elem
End Sub


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