次の方法で共有


Control.DefaultFont プロパティ

定義

コントロールの既定のフォントを取得します。

public:
 static property System::Drawing::Font ^ DefaultFont { System::Drawing::Font ^ get(); };
public static System.Drawing.Font DefaultFont { get; }
static member DefaultFont : System.Drawing.Font
Public Shared ReadOnly Property DefaultFont As Font

プロパティ値

コントロールの既定の Font 。 返される値は、ユーザーのオペレーティング システムのシステムのローカル カルチャ設定によって異なります。

例外

既定のフォントまたは地域の代替フォントは、クライアント コンピューターにインストールされません。

次のコード例は、 DefaultBackColorDefaultFont、および DefaultForeColor メンバーの使用方法を示しています。 この例を実行するには、ListBox1 という名前の ListBox を含むフォームに次のコードを貼り付けます。 フォームのコンストラクターで Populate_ListBox メソッドを呼び出すか、イベント処理メソッド Load 呼び出します。

// The following method displays the default font, 
// background color and foreground color values for the ListBox  
// control. The values are displayed in the ListBox, itself.
void Populate_ListBox()
{
   ListBox1->Dock = DockStyle::Bottom;
   
   // Display the values in the read-only properties 
   // DefaultBackColor, DefaultFont, DefaultForecolor.
   ListBox1->Items->Add( String::Format( "Default BackColor: {0}", ListBox::DefaultBackColor ) );
   ListBox1->Items->Add( String::Format( "Default Font: {0}", ListBox::DefaultFont ) );
   ListBox1->Items->Add( String::Format( "Default ForeColor:{0}", ListBox::DefaultForeColor ) );
}

// The following method displays the default font, 
// background color and foreground color values for the ListBox  
// control. The values are displayed in the ListBox, itself.

private void Populate_ListBox()
{
    ListBox1.Dock = DockStyle.Bottom;

    // Display the values in the read-only properties 
    // DefaultBackColor, DefaultFont, DefaultForecolor.
    ListBox1.Items.Add("Default BackColor: " + 
        ListBox.DefaultBackColor.ToString());
    ListBox1.Items.Add("Default Font: " + 
        ListBox.DefaultFont.ToString());
    ListBox1.Items.Add("Default ForeColor:" + 
        ListBox.DefaultForeColor.ToString());
}

' The following method displays the default font, 
' background color and foreground color values for the ListBox  
' control. The values are displayed in the ListBox, itself.

Private Sub Populate_ListBox()
    ListBox1.Dock = DockStyle.Bottom

    ' Display the values in the read-only properties 
    ' DefaultBackColor, DefaultFont, DefaultForecolor.
    ListBox1.Items.Add("Default BackColor: " & ListBox.DefaultBackColor.ToString)
    ListBox1.Items.Add("Default Font: " & ListBox.DefaultFont.ToString)
    ListBox1.Items.Add("Default ForeColor:" & ListBox.DefaultForeColor.ToString)

End Sub

注釈

次の表では、オペレーティング システムとローカル カルチャに応じて、 DefaultFont によって返される値について説明します。

システムまたはカルチャ フォント
Windows NT 4x、日本語バージョン MS UI ゴシック、9 ポイント。
アラビア語 (Windows) タホマ、8 ポイント。
その他のオペレーティング システム/カルチャ MS シェル Dlg 論理フォント (通常は Microsoft San Serif 8 ポイント)。

MS シェル Dlg は、システム レジストリのフォント セットにマップされます。

前のフォントがインストールされていない場合、既定のフォントは Tahoma (8 ポイント) です。 8 ポイントの Tahoma がインストールされていない場合、 DefaultFontGenericSansSerif プロパティの値を返します。

適用対象

こちらもご覧ください