FontDialog::Font Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the selected font.

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

property Font^ Font {
	Font^ get();
	void set(Font^ value);

Property Value

Type: System.Drawing::Font^

The selected font.

The following code example uses ShowDialog to display a FontDialog. This code requires that a Form has already been created with a TextBox and button placed on it. It also requires that the fontDialog1 has been created. The Font contains the size information but not the color information.

   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;

.NET Framework
Available since 1.1
Return to top