我有一个有两个属性的小类
public class ColorPair
{
#region Miembros
private Color _BackColor;
private Color _ForeColor;
#endregion
#region Auxiliares
[Browsable(true)]
[Category("Color pair")]
[Description("Back color")]
[DefaultValue(typeof(Color), "White")]
public Color BackColor
{
get { return _BackColor; }
set{ _BackColor = value; }
}
[Browsable(true)]
[Category("Color pair")]
[Description("Fore color")]
[DefaultValue(typeof(Color), "White")]
public Color ForeColor
{
get { return _ForeColor; }
set
{
_ForeColor = value;
}
}
#endregion
public ColorPair()
{
_BackColor = Color.White;
_ForeColor = Color.Black;
}
public ColorPair(Color pFore, Color pBack)
{
_BackColor = pFore;
_ForeColor = pBack;
}
}
我需要将其用作控件中的属性,如下所示:
[Browsable(true)]
[Category("Trevo format")]
[Description("Basic color")]
[DefaultValue(typeof(ColorPair), "new ColorPair()")]
public ColorPair Normal
{
get { return _Normal; }
set
{
_Normal = value;
this.Invalidate();
}
}
但是,当我去找设计师时,该属性似乎已禁用。有没有办法让它能够收集值?
谢谢你。