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 apply formats to the HTML elements in WinForms HTMLUIControl?

Platform: WinForms |
Control: HTMLUIControl

HTML format

The formatting feature of the HTMLUI allows the users to change the style of a specific HTML element at run-time. The format for an element is implemented with the help of the HTMLFormat class. This class implements the IHTMLFormat interface.

The div element can be formatted at run-time as shown below.


HTMLFormat format = new HTMLFormat("Applied Format");
Hashtable html = this.htmluiControl1.Document.GetElementsByUserIdHash();
DIVElementImpl div1 = this.html["div1"] as DIVElementImpl;
this.div1.Click += new EventHandler(div1_Click);
format.Font = new Font("Arial", 10);
format.ForeColor = Color.SeaGreen;
private void div1_Click(object sender, EventArgs e)
    this.div1.Format = format;


Private format As HTMLFormat = New HTMLFormat("Applied Format")
Private html As Hashtable = Me.htmluiControl1.Document.GetElementsByUserIdHash()
Private div1 As DIVElementImpl = CType(IIf(TypeOf Me.html("div1") Is DIVElementImpl,
Me.html("div1"), Nothing), DIVElementImpl)
Private Me.div1.Click += New EventHandler(div1_Click)
Private format.Font = New Font("Arial", 10)
Private format.ForeColor = Color.SeaGreen
Private Sub div1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Me.div1.Format = format
End Sub


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

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