Articles in this section
Category / Section

How to apply formats to the HTML elements in WinForms HTMLUIControl?

1 min read

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.

C#

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;
}

VB

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

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