次の方法で共有


Font コンストラクタ (Font, FontStyle)

指定した既存の FontFontStyle 列挙体を使用する、新しい Font を初期化します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)

構文

'宣言
Public Sub New ( _
    prototype As Font, _
    newStyle As FontStyle _
)
'使用
Dim prototype As Font
Dim newStyle As FontStyle

Dim instance As New Font(prototype, newStyle)
public Font (
    Font prototype,
    FontStyle newStyle
)
public:
Font (
    Font^ prototype, 
    FontStyle newStyle
)
public Font (
    Font prototype, 
    FontStyle newStyle
)
public function Font (
    prototype : Font, 
    newStyle : FontStyle
)

パラメータ

  • prototype
    新しい Font の作成元となる既存の Font
  • newStyle
    新しい Font に適用する FontStyleFontStyle 列挙体の複数の値を OR 演算子と組み合わせることができます。

使用例

op_Inequality 演算子、Font コンストラクタ、および Bold プロパティを使用するコード例を次に示します。この例は、Button2 という名前のボタンを含んだ Windows フォームでの使用を意図してデザインされています。次のコードをフォームに貼り付け、Button2_Click メソッドをボタンの Click イベントに関連付けます。

Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    If (Color.op_Inequality(Me.BackColor, SystemColors.ControlDark)) Then
        Me.BackColor = SystemColors.ControlDark
    End If
    If Not (Me.Font.Bold) Then
        Me.Font = New Font(Me.Font, FontStyle.Bold)
    End If
End Sub
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);
    }
}
void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   if ( this->BackColor != SystemColors::ControlDark )
   {
      this->BackColor = SystemColors::ControlDark;
   }

   if (  !(this->Font->Bold) )
   {
      this->Font = gcnew System::Drawing::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 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

Font クラス
Font メンバ
System.Drawing 名前空間