Partager via


Control.DefaultForeColor Propriété

Définition

Obtient la couleur de premier plan par défaut du contrôle.

public:
 static property System::Drawing::Color DefaultForeColor { System::Drawing::Color get(); };
public static System.Drawing.Color DefaultForeColor { get; }
static member DefaultForeColor : System.Drawing.Color
Public Shared ReadOnly Property DefaultForeColor As Color

Valeur de propriété

Premier plan Color par défaut du contrôle. La valeur par défaut est ControlText.

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

Il s’agit de la valeur de propriété par défaut ForeColor d’un contrôle nonparenté. Les classes dérivées peuvent avoir des valeurs par défaut différentes.

S’applique à

Voir aussi