Condividi tramite


Control.DefaultFont Proprietà

Definizione

Ottiene il tipo di carattere predefinito del controllo.

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

Valore della proprietà

Impostazione predefinita Font del controllo . Il valore restituito varia a seconda del sistema operativo dell'utente dell'impostazione delle impostazioni cultura locali del sistema.

Eccezioni

Il tipo di carattere predefinito o i tipi di carattere alternativi internazionali non vengono installati nel computer client.

Esempio

Nell'esempio di codice seguente viene illustrato come usare i DefaultBackColormembri , DefaultFonte DefaultForeColor . Per eseguire l'esempio, incollare il codice seguente in un modulo contenente un ListBox oggetto denominato ListBox1. Chiamare il Populate_ListBox metodo nel costruttore del modulo o Load nel metodo di gestione degli eventi.

// 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

Commenti

Nella tabella seguente viene descritto il valore restituito da DefaultFont a seconda del sistema operativo e delle impostazioni cultura locali.

Impostazioni cultura e/o di sistema Carattere
Windows NT 4x, versione giapponese MS UI Gothic, 9 punti.
Finestre arabe Tahoma, 8 punti.
Altri sistemi operativi/impostazioni cultura Tipo di carattere logico MS Shell Dlg, in genere Microsoft San Serif 8 punti.

MS Shell Dlg esegue il mapping a un set di tipi di carattere nel Registro di sistema.

Se i tipi di carattere precedenti non sono installati, il tipo di carattere predefinito è Tahoma, 8 punti. Se Tahoma, 8 punti, non è installato, DefaultFont restituisce il valore della GenericSansSerif proprietà

Si applica a

Vedi anche