Getting Started with Windows Forms Html Viewer (HTMLUI)

13 Oct 20223 minutes to read

This section describes how to configure a HTMLUIControl in a Windows Forms application and overview of its basic functionalities.

Assembly deployment

Refer control dependencies section to get the list of assemblies or NuGet package needs to be added as reference to use the control in any application.

Get more details regarding how to install the nuget packages in windows form application in the How to install nuget packages link.

Creating simple application with HTMLUIControl

You can create Windows Forms application with HTMLUIControl as follows:

  1. Creating the project
  2. Adding control via designer
  3. Adding control manually using code
  4. Loading a file into document

Creating the project

Create a new Windows Forms project in Visual Studio to display the HTMLUIControl.

Adding control via designer

The HTMLUIControl can be added to the application by dragging it from the toolbox and dropping it in the designer view. The following required assembly references will be added automatically:

  • Syncfusion.HTMLUI.Base.dll
  • Syncfusion.HTMLUI.Windows.dll
  • Syncfusion.Scripting.Base.dll
  • Syncfusion.Shared.Base

Search html ui control in toolbox

Drag an drop the html ui control in application

Configure Title

Title text can be set using Title property. The visibility of the title can be customized using ShowTitle property.

Setting tile for html ui control

Adding control manually using code

To add the control manually in C#, follow the steps:

Step 1 : Add the following required assembly references to the project:

  * Syncfusion.HTMLUI.Base.dll
  * Syncfusion.HTMLUI.Windows.dll
  * Syncfusion.Scripting.Base.dll
  * Syncfusion.Shared.Base

Step 2 : Include the namespaces Syncfusion.Windows.Forms.HTMLUI.

using Syncfusion.Windows.Forms.HTMLUI;
Imports Syncfusion.Windows.Forms.HTMLUI

Step 3 : Create the HTMLUIControl instance and add it to the form.

HTMLUIControl htmluiControl1 = new HTMLUIControl();

this.htmluiControl1.Dock = System.Windows.Forms.DockStyle.Fill;

this.htmluiControl1.Text = "htmluiControl1";

this.Controls.Add(this.htmluiControl1);
Dim htmluiControl1 As New HTMLUIControl()

Me.htmluiControl1.Dock = System.Windows.Forms.DockStyle.Fill

Me.htmluiControl1.Text = "htmluiControl1"

Me.Controls.Add(Me.htmluiControl1)

HTMLUIControl added using code

Configure Title

Title text can be set using Title property. The visibility of the title can be customized using ShowTitle property.

this.htmluiControl1.ShowTitle = true;
this.htmluiControl1.Title = "StartUp Document";
Me.htmluiControl1.ShowTitle = True
Me.htmluiControl1.Title = "StartUp Document"

Setting title for HTMLUIControl

Loading a file into document

File can be added to HTMLUIControl using LoadHTML method where the file path given as parameter.

this.htmluiControl1.LoadHTML(Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\FileName.htm");
Me.htmluiControl1.LoadHTML(Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\FileName.htm")

HTMLUI control loads the given input file