Partager via


Control.DefaultFont Propriété

Définition

Obtient la police par défaut du contrôle.

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

Valeur de propriété

Valeur par défaut Font du contrôle. La valeur retournée varie selon le système d’exploitation de l’utilisateur, le paramètre de culture locale de son système.

Exceptions

La police par défaut ou les autres polices régionales ne sont pas installées sur l’ordinateur client.

Exemples

L’exemple de code suivant montre comment utiliser les membres DefaultFontet DefaultForeColor les DefaultBackColormembres. Pour exécuter l’exemple, collez le code suivant dans un formulaire contenant un ListBox listBox1 appelé. Appelez la méthode dans le Populate_ListBox constructeur du formulaire ou Load la méthode de gestion des événements.

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

Remarques

Le tableau suivant décrit la valeur retournée DefaultFont en fonction du système d’exploitation et de la culture locale.

Système/et culture Police
Windows NT 4x, version japonaise MS UI Gothique, 9 points.
Windows arabe Tahoma, 8 points.
Autre système d’exploitation/culture Police logique MS Shell Dlg, généralement Microsoft San Serif 8 points.

MS Shell Dlg mappe à un jeu de polices dans le Registre système.

Si les polices précédentes ne sont pas installées, la police par défaut est Tahoma, 8 points. Si Tahoma, 8 points, n’est pas installé, DefaultFont retourne la valeur de la GenericSansSerif propriété

S’applique à

Voir aussi