Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Propiedad MonthCalendar.BackColor

 

Publicado: octubre de 2016

Obtiene o establece el color de fondo del control.

Espacio de nombres:   System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)

public override Color BackColor { get; set; }

Valor de propiedad

Type: System.Drawing.Color

Objeto Color que representa el color de fondo del control. El valor predeterminado es el valor de la propiedad DefaultBackColor.

The P:System.Windows.Forms.Control.BackColor property does not support transparent colors unless the SupportsTransparentBackColor value of T:System.Windows.Forms.ControlStyles is set to true.

The P:System.Windows.Forms.Control.BackColor 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();.

Notas para desarrolladores de herederos:

When overriding the P:System.Windows.Forms.Control.BackColor property in a derived class, use the base class's P:System.Windows.Forms.Control.BackColor 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.BackColor 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;
   if(control.HasChildren)
   {
      // Recursively call this method for each child control.
      foreach(Control childControl in control.Controls)
      {
         ResetAllControlsBackColor(childControl);
      }
   }
}

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: