Sdílet prostřednictvím


Control.DefaultForeColor Vlastnost

Definice

Získá výchozí barvu popředí ovládacího prvku.

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

Hodnota vlastnosti

Výchozí popředí Color ovládacího prvku. Výchozí hodnota je ControlText.

Příklady

Následující příklad kódu ukazuje, jak používat DefaultBackColor, DefaultFonta DefaultForeColor členové. Pokud chcete spustit příklad, vložte následující kód do formuláře obsahujícího ListBox název ListBox1. Volejte metodu Populate_ListBox v konstruktoru formuláře nebo Load metodě zpracování událostí.

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

Poznámky

Toto je výchozí ForeColor hodnota vlastnosti neparentovaného ovládacího prvku. Odvozené třídy mohou mít různé výchozí hodnoty.

Platí pro

Viz také