System.Windows.Forms.Control.Font Property

Gets or sets the font of the text displayed by the control.

Syntax

[System.ComponentModel.Localizable(true)]
[System.ComponentModel.AmbientValue(null)]
[System.Runtime.InteropServices.DispId(-512)]
public virtual System.Drawing.Font Font { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

The Control.Font property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a System.Windows.Forms.Button will have the same Control.BackColor as its parent System.Windows.Forms.Form by default. For more information about ambient properties, see the System.Windows.Forms.AmbientProperties class or the System.Windows.Forms.Control class overview.

Because the System.Drawing.Font is immutable (meaning that you cannot adjust any of its properties), you can only assign the Control.Font property a new System.Drawing.Font. However, you can base the new font on the existing font.

[Visual Basic, C#]

The following is an example of how to adjust the existing font to make it bold:

Example

myControl.Font = new Font(myControl.Font, 
    myControl.Font.Style | FontStyle.Bold);

Example

MyControl.Font = New Font(MyControl.Font, _ 
    MyControl.Font.Style Or FontStyle.Bold)

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0