将此类序列化为属性集合时遇到问题,它是另一个属性集合的一部分,并在那里列为:
`[PropertyTab("AddCellRules"),
Browsable(true),
Description("Add Cell Rules"), Category("ColumnProperties"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Collection<CellRules> CellRules { get; set; }`
实际班级:
`[Serializable]
public class CellRules
{
private bool compliment;
private Color backColor;
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("BackgroundColor"), Category("CellProperties"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Color BackgroundColor
{
get
{
return backColor;
}
set
{
if (compliment)
{
ForeColor = SetForeColor(value);
}
backColor = value;
}
}
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("ComplimentBackColor"), Category("CellProperties"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public bool ComplimentBackColor {
get
{
return compliment;
}
set
{
if (value)
{
ForeColor = SetForeColor(BackgroundColor);
}
compliment = value;
}
}
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("ForeColor"), Category("CellProperties")]
public Color ForeColor { get; set; }
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("FontType"), Category("CellProperties"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Font FontType { get; set; }
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("FontStyles"), Category("CellProperties"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public FontStyle FontStyles { get; set; }
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("TriggerOnData"), Category("CellProperties")]
public bool TriggerOnData { get; set; }
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("DataTrigger"), Category("CellProperties")]
public String DataTrigger { get; set; }
[PropertyTab("AddExtendedCellProperty")]
[Browsable(true)]
[Description("TrggerOperator"), Category("CellProperties")]
public Operator TrggerOperator { get; set; }
[PropertyTab("AddExtendedColumnProperty")]
[Browsable(true)]
[Description("Pivot"), Category("ColumnProperties")]
public PivotTypes Pivot { get; set; }
[PropertyTab("AddExtendedColumnProperty")]
[Browsable(true)]
[Description("InitialPivot"), Category("ColumnProperties")]
public bool InitialPivot { get; set; }
[PropertyTab("AddExtendedColumnProperty")]
[Browsable(true)]
[Description("Alignment"), Category("ColumnProperties")]
public DataGridViewContentAlignment ContentAlignment { get; set; }
public CellRules()
{
Pivot = PivotTypes.none;
BackgroundColor = Cell_GlobalVars.backgroundColor;
ForeColor = Cell_GlobalVars.foreColor;
FontType = Cell_GlobalVars.fontType;
FontStyles = Cell_GlobalVars.fontStyles;
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
private Color SetForeColor(Color Colors)
{
Color result = Color.Black;
double Brightness = Math.Sqrt(.299 * Math.Pow(Colors.R, 2) + .587 * Math.Pow(Colors.G, 2) + .114 * Math.Pow(Colors.B, 2));
if (Brightness < 130)
result = Color.White;
return result;
}
}`
我确实运行了serTool并且没有错误,任何想法?...