Articles in this section
Category / Section

How to change the base font size of the document rendered by the WinForms HTMLUIControl at run time?

1 min read

Font size

The HTMLUI control allows the user to access the default format used for rendering the html document. The DefaultFormat.Font property helps in getting or setting the base font and its size while rendering in the HTMLUI control.

As like in popular web browsers, the user can change the font and increase or decrease the font size by changing the DefaultFormat.Font property of the HTMLUI control. The following code snippet shows how the base font size is changed during run time.

C#

//Increasing the font size at run time by clicking a button
FontIncButton.Click += new System.EventHandler(FontIncButton_Click);
private void FontIncButton_Click(object sender, System.EventArgs e)
{
  //Increasing the DefaultFormat font size
  float fontSize = htmluiControl.DefaultFormat.Font.Size + 3;
  //Applying the changed size to the default format
  htmluiControl.DefaultFormat.Font = new Font(htmluiControl.DefaultFormat.Font.FontFamily, fontSize);
}

 

VB

'Increasing the font size at run time by clicking a button
Private FontIncButton.Click += New System.EventHandler(FontIncButton_Click)
Private Sub FontIncButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  'Increasing the DefaultFormat font size
  Dim fontSize As Single = htmluiControl.DefaultFormat.Font.Size + 3
  'Applying the changed size to the default format
  htmluiControl.DefaultFormat.Font = New Font(htmluiControl.DefaultFormat.Font.FontFamily, fontSize)
End Sub

 

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