---
title: "How to: Show a Font List with the FontDialog Component"
ms.date: "03/30/2017"
dev_langs: 
  - "csharp"
  - "vb"
  - "cpp"
helpviewer_keywords: 
  - "fonts [Windows Forms], showing list"
  - "FontDialog component [Windows Forms]"
  - "fonts [Windows Forms], attributes"
  - "Font property [Windows Forms], setting with FontDialog component"
  - "Font dialog box [Windows Forms], displaying"
  - "fonts [Windows Forms], selecting"
ms.assetid: 35692c1b-0937-4b7a-9207-1ae6bdc244a0
---
# How to: Show a Font List with the FontDialog Component
The [FontDialog](fontdialog-component-windows-forms.md) component allows users to select a font, as well as change its display aspects, such as its weight and size.  
  
 The font selected in the dialog box is returned in the <xref:System.Windows.Forms.FontDialog.Font%2A> property. Thus, taking advantage of the font selected by the user is as easy as reading a property.  
  
### To select font properties using the FontDialog Component  
  
1. Display the dialog box using the <xref:System.Windows.Forms.CommonDialog.ShowDialog%2A> method.  
  
2. Use the <xref:System.Windows.Forms.DialogResult> property to determine how the dialog box was closed.  
  
3. Use the <xref:System.Windows.Forms.FontDialog.Font%2A> property to set the desired font.  
  
     In the example below, the <xref:System.Windows.Forms.Button> control's <xref:System.Windows.Forms.Control.Click> event handler opens a <xref:System.Windows.Forms.FontDialog> component. When a font is chosen and the user clicks **OK**, the <xref:System.Windows.Forms.FontDialog.Font%2A> property of a <xref:System.Windows.Forms.TextBox> control that is on the form is set to the chosen font. The example assumes your form has a <xref:System.Windows.Forms.Button> control, a  <xref:System.Windows.Forms.TextBox> control, and a <xref:System.Windows.Forms.FontDialog> component.  
  
    ```vb  
    Private Sub Button1_Click(ByVal sender As System.Object, _  
       ByVal e As System.EventArgs) Handles Button1.Click  
       If FontDialog1.ShowDialog() = DialogResult.OK Then  
          TextBox1.Font = FontDialog1.Font  
       End If  
    End Sub  
    ```  
  
    ```csharp  
    private void button1_Click(object sender, System.EventArgs e)  
    {  
       if(fontDialog1.ShowDialog() == DialogResult.OK)  
       {  
          textBox1.Font = fontDialog1.Font;  
       }  
    }  
    ```  
  
    ```cpp  
    private:  
       void button1_Click(System::Object ^ sender,  
          System::EventArgs ^ e)  
       {  
          if(fontDialog1->ShowDialog() == DialogResult::OK)  
          {  
             textBox1->Font = fontDialog1->Font;  
          }  
       }  
    ```  
  
     (Visual C# and Visual C++) Place the following code in the form's constructor to register the event handler.  
  
    ```csharp  
    this.button1.Click += new System.EventHandler(this.button1_Click);  
    ```  
  
    ```cpp  
    button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);  
    ```  
  
## See also

- <xref:System.Windows.Forms.FontDialog>
- [FontDialog Component](fontdialog-component-windows-forms.md)
