Control.DefaultBackColor Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft die Standardhintergrundfarbe des Steuerelements ab.
public:
static property System::Drawing::Color DefaultBackColor { System::Drawing::Color get(); };
public static System.Drawing.Color DefaultBackColor { get; }
static member DefaultBackColor : System.Drawing.Color
Public Shared ReadOnly Property DefaultBackColor As Color
Eigenschaftswert
Der Standardhintergrund Color des Steuerelements. Der Standardwert lautet Control.
Beispiele
Im folgenden Codebeispiel wird veranschaulicht, wie die DefaultBackColorElemente und DefaultForeColor die Elemente DefaultFontverwendet werden. Zum Ausführen des Beispiels fügen Sie den folgenden Code in ein Formular mit dem ListBox Namen ListBox1 ein. Rufen Sie die Methode im Konstruktor oder Load in der Populate_ListBox Ereignisbehandlungsmethode des Formulars auf.
// 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
Hinweise
Dies ist der Standardwert BackColor eines generischen Steuerelements auf oberster Ebene. Abgeleitete Klassen können unterschiedliche Standardwerte aufweisen.