Export (0) Print
Expand All

Font.Font(Font, FontStyle) Constructor

Initializes a new Font that uses the specified existing Font and FontStyle enumeration.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public Font (
	Font prototype,
	FontStyle newStyle
)
public Font (
	Font prototype, 
	FontStyle newStyle
)
public function Font (
	prototype : Font, 
	newStyle : FontStyle
)
Not applicable.

Parameters

prototype

The existing Font from which to create the new Font.

newStyle

The FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator.

For localized applications that are based on the .NET Framework 2.0 and earlier releases, specifying a font for prototype when that font has not been installed on the computer that is used to build your application will cause the Microsoft Sans Serif font to be used instead. If your application depends on this behavior and you must recompile your application for the .NET Framework 3.0, you should specify the Microsoft Sans Serif font for prototype.

The following code example demonstrates the op_Inequality operator, the Font constructor, and the Bold property. This example is designed to be used with a Windows Form that contains a button named Button2. Paste the following code into your form and associate the Button2_Click method with the button's Click event.

private void Button2_Click(System.Object sender, System.EventArgs e)
{

    if (this.BackColor != SystemColors.ControlDark)
    {
        this.BackColor = SystemColors.ControlDark;
    }
    if (!(this.Font.Bold))
    {
        this.Font = new Font(this.Font, FontStyle.Bold);
    }
}

private void button2_Click(System.Object sender, System.EventArgs e)
{
    if (!(this.get_BackColor().Equals(SystemColors.get_ControlDark()))) {
        this.set_BackColor(SystemColors.get_ControlDark());
    }
    if (!(this.get_Font().get_Bold())) {
        this.set_Font(new Font(this.get_Font(), FontStyle.Bold));
    }
} //button2_Click

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft