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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I apply formats to the HTML elements?


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.

An HTML document containing a div element is shown below.


Syncfusion's products/components are written in C#. These components can be used in C#, VB.NET or any other .NET language.

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

Article ID: Published Date: Last Revised Date: Platform: Control:
803 04/30/2011 07/10/2014 WinForms HTMLUIControl
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

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

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