I am creating a user control with a black background, but it has some problems with the designer. In truth, I have a base control class that inherits from UserControl, and then some subclasses that represent the final controls that I will use in my GUI. In this base class, I override a property BackColor, add an attribute, DefaultValueand set the default value BackColorin the constructor. As an example, my code looks something like this:
public partial class MyControl1 : UserControl
{
public MyControl1()
{
InitializeComponent();
BackColor = Color.Black;
}
[DefaultValue(typeof(Color),"Black")]
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
}
...
public partial class MyControl2 : MyControl1
{
public MyControl2()
{
InitializeComponent();
}
}
, MyControl2, BackColor System.Drawing.SystemColors.Control, . Reset BackColor, , , Color.Black. , System.Drawing.SystemColors.Control, .
, ?
, BackColor, , AmbientValue(false). , .
, BackColor=Color.Black . , System.Drawing.SystemColors.Control. ResetBackColor() .
, Visual Studio 2010, Windows Forms.NET 2.0.
, - - . , , . !