ComponentOne Input for WinForms
Using the C1Input Controls / C1Input Controls / C1FontPicker Control Overview / Working with C1FontPicker
In This Topic
    Working with C1FontPicker
    In This Topic

    This topic illustrates how to use C1FontPicker for Windows Forms applications. The steps to set up Visual Studio project and customize the application during runtime are as follows:

    1. Create a Windows Forms project and add C1FontPicker control to the Form.
    2. Add RichTextBox control to the Form. Set the Text property of the RichTextBox to TextFontStyle.
    3. Add the following code to the C1FontPicker1_ValueChanged event handler to change the font of the text on font selection:
      VB
      Copy Code
      Private Sub C1FontPicker1_ValueChanged(sender As Object, e As EventArgs) Handles C1FontPicker1.ValueChanged
          RichTextBox1.SelectionFont = New Font(DirectCast(sender, C1FontPicker).Value.ToString(), RichTextBox1.SelectionFont.Size, RichTextBox1.SelectionFont.Style)
      End Sub
      
      C#
      Copy Code
      private void c1FontPicker1_ValueChanged(object sender, EventArgs e)
      {
          richTextBox1.SelectionFont = new Font(((C1FontPicker)sender).Value.ToString(), richTextBox1.SelectionFont.Size, richTextBox1.SelectionFont.Style);
      }
      
    4. Run the application. Now you can select the font from C1FontPicker drop-down. The following image shows the output:
      workingwithfontpicker               
    See Also