Preventing wincode on custom control?

  • Thread starter Thread starter Brett Romero
  • Start date Start date
B

Brett Romero

I have a custom control that defines

this.AlternatingBackColor = System.Drawing.Color.Lavender;

in its constructor. When I add this control from my VS.NET 2003
toolbar and drop it onto a form, the same line of code is generated in
the form's InitializeComponent():

this.customGrid.AlternatingBackColor = System.Drawing.Color.Lavender;

which generates a run time error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll

Additional information: The data grid table styles collection already
contains a table style with the same mapping name.


How do I prevent the wincode from being generated for the custom
control?

Thanks,
Brett
 
Actually, this was coming from the datagridstyle. Not sure how it got
there but I define one in the control. Removing these lines fixed it:

this.dataGridTableStyle2.DataGrid = this.dgRelative;
this.dataGridTableStyle2.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle2.MappingName = "default";

Brett
 
Actually, the IDE, compiler, or some stubborn piece of code somewhere
keeps adding these back as style3, style4, style5, etc. I need some
way to just slap its hand and say stop doing that. Any ideas?

Thanks,
Brett
 
Back
Top