Dieser Artikel wurde maschinell übersetzt. Wenn Sie die englische Version des Artikels anzeigen möchten, aktivieren Sie das Kontrollkästchen Englisch. Sie können den englischen Text auch in einem Popupfenster anzeigen, indem Sie den Mauszeiger über den Text bewegen.



Ruft die Schriftfarbe des Steuerelements ab oder legt diese fest.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public override Color ForeColor { get; set; }


Type: System.Drawing.Color

Die Vordergrund-Color des Steuerelements. Der Standardwert ist der Wert der DefaultForeColor-Eigenschaft.

The P:System.Windows.Forms.Control.ForeColor property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a T:System.Windows.Forms.Button will have the same P:System.Windows.Forms.Control.BackColor as its parent T:System.Windows.Forms.Form by default. For more information about ambient properties, see the T:System.Windows.Forms.AmbientProperties class or the T:System.Windows.Forms.Control class overview.

Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the Enable XP visual styles check box. To disable visual styles in C#, open Program.cs and comment out Application.EnableVisualStyles();.

Hinweise zur Vererbung:

When overriding the P:System.Windows.Forms.Control.ForeColor property in a derived class, use the base class's P:System.Windows.Forms.Control.ForeColor property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the P:System.Windows.Forms.Control.ForeColor property; you can override only one if needed.

The following code example sets the P:System.Windows.Forms.Control.BackColor and P:System.Windows.Forms.Control.ForeColor of the controls to the default system colors. The code recursively calls itself if the control has any child controls. This code example requires that you have a T:System.Windows.Forms.Form with at least one child control; however, a child container control, like a T:System.Windows.Forms.Panel or T:System.Windows.Forms.GroupBox, with its own child control(s) would better demonstrate the recursion.

// Reset all the controls to the user's default Control color. 
private void ResetAllControlsBackColor(Control control)
   control.BackColor = SystemColors.Control;
   control.ForeColor = SystemColors.ControlText;
      // Recursively call this method for each child control.
      foreach(Control childControl in control.Controls)

.NET Framework
Verfügbar seit 1.1
Zurück zum Anfang