Go to GoReading for breaking news, videos, and the latest top stories in world news, business, politics, health and pop culture.

How to Change the RichEdit Font by Using the ComboBox List of Fonts in Visual Basic

104 3
    • 1). Add the following Imports statements into the top of the form file containing the text editor and combo box:

      Imports System.Drawing
      Imports System.Drawing.Text

    • 2). Copy and Paste the following code into your form class:

      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim ifc As InstalledFontCollection = New InstalledFontCollection()
      ComboBox1.Items.AddRange(ifc.Families)
      End Sub

      Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
      RichTextBox1.Font = New Font(ComboBox1.SelectedText, 12)
      End Sub

    • 3). Press "F5" to run your application. The Combo Box control will have all the computer's installed fonts. When you change the font, the RichTextEditor will use the font you selected.

Source...

Leave A Reply

Your email address will not be published.