I have a custom DataGridView
, let's say as such:
public MyGridView : DataGridView
{
public MyGridView()
{
BackgroundColor = Color.Red;
}
}
Now, when I use this control in a project using the designer, for some reason it feels a need to also set the property in the designer.cs file.
So in the designer file, I would have:
this.MyGridView1.BackgroundColor = System.Drawing.Color.FromArgb((byte)(int)255, (byte)(int)0, (byte)(int)0);
The problem me with this is that it prevents me from being able to change the color in the constructor of my MyGridView
, without having to go through all the forms in which I used to control and change it per instance, rendering my custom control useless.
With some properties which offer a virtual getter, this is no problem, but most properties do not have it.
How can I prevent the designer from generating this code?
DataGridView
(.e.gBackgroundColor
). Where would I add the attribute? – Ethnicconst
able values. Is there a way to assign a default value attribute to non-const
able value types? – Ethnic