This documentation is archived and is not being maintained.

FontDialog Class

Represents a common dialog box that displays a list of fonts that are currently installed on the system.

For a list of all members of this type, see FontDialog Members.


[Visual Basic]
Public Class FontDialog
   Inherits CommonDialog
public class FontDialog : CommonDialog
public __gc class FontDialog : public CommonDialog
public class FontDialog extends CommonDialog

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


The inherited member ShowDialog must be invoked to create this specific common dialog box. HookProc can be overridden to implement specific dialog box hook functionality.

When you create an instance of FontDialog, some of the read/write properties are set to initial values. For a list of these values, see the FontDialog constructor.


[Visual Basic, C#, C++] The following example uses ShowDialog to display a FontDialog. This code assumes that a Form has already been created with a TextBox and button placed on it. It also assumes the fontDialog1 has been created. The Font contains the size information but not the color information.

[Visual Basic] 
Protected Sub button1_Click(sender As Object, e As System.EventArgs)
    fontDialog1.ShowColor = True

    fontDialog1.Font = textBox1.Font
    fontDialog1.Color = textBox1.ForeColor

    If fontDialog1.ShowDialog() <> DialogResult.Cancel Then
        textBox1.Font = fontDialog1.Font
        textBox1.ForeColor = fontDialog1.Color
    End If
End Sub 'button1_Click

protected void button1_Click(object sender, System.EventArgs e)
    fontDialog1.ShowColor = true;

    fontDialog1.Font = textBox1.Font;
    fontDialog1.Color = textBox1.ForeColor;

    if(fontDialog1.ShowDialog() != DialogResult.Cancel )
       textBox1.Font = fontDialog1.Font ;
       textBox1.ForeColor = fontDialog1.Color;

void button1_Click(Object* /*sender*/, System::EventArgs* /*e*/)
    fontDialog1->ShowColor = true;

    fontDialog1->Font = textBox1->Font;
    fontDialog1->Color = textBox1->ForeColor;

    if(fontDialog1->ShowDialog() != DialogResult::Cancel )
       textBox1->Font = fontDialog1->Font ;
       textBox1->ForeColor = fontDialog1->Color;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

FontDialog Members | System.Windows.Forms Namespace | CommonDialog | Font