M
Mario Vasquez
I am creating a custom button, derived from System.Windows.Forms.Button.
In this new control I assign in the constructor a size for itself,
because I need that to be a fixed one: e.g.,
public CustomButton()
{
....
this.Size = new Size(32, 23);
....
}
since this property is not overridable, I had to create a new property
called Size which hides the base property, so that I can assign a
DefaultValue attribute on it, like so:
[DefaultValue(typeof(Size), DEFAULT_SIZE)]
public new Size Size
{
get { return base.Size; }
set { base.Size = value; }
}
When this button is inserted in a form, the designer always creates a
new line...
this.customButton1.Size = new Size(32, 23);
how to avoid this line (obviously without having to delete it by hand),
so if I change my class' default value, this will be propagated across
my instantiated objects?
In this new control I assign in the constructor a size for itself,
because I need that to be a fixed one: e.g.,
public CustomButton()
{
....
this.Size = new Size(32, 23);
....
}
since this property is not overridable, I had to create a new property
called Size which hides the base property, so that I can assign a
DefaultValue attribute on it, like so:
[DefaultValue(typeof(Size), DEFAULT_SIZE)]
public new Size Size
{
get { return base.Size; }
set { base.Size = value; }
}
When this button is inserted in a form, the designer always creates a
new line...
this.customButton1.Size = new Size(32, 23);
how to avoid this line (obviously without having to delete it by hand),
so if I change my class' default value, this will be propagated across
my instantiated objects?