windows form inheritance

  • Thread starter Thread starter Iwan Petrow
  • Start date Start date
I

Iwan Petrow

Hi,

I have one base form which has a panel control. I made the panel
control protected because I want to add controls in it. When I inhert
it using visual studio designer and add controls (anywhere in the form)
the designer add one row: this.myPanel.Size=.... and in this way I have
problems with the size of the panel control.

Could I do something that this not to happen? I want properties of the
panel control to be like these in the base class and not to change (I
want only other controls to be added in it).


Thanks.
 
You would have to create your own type of Panel, that inherits from
Panel, and declares a different default size using

private void ShouldSerializeSize()
{
return this.Height != defaultHeight || this.Width != defaultWidth;
}

where "defaultHeight" and "defaultWidth" are constants in your derived
panel. Even better, make them fields and create public properties for
them, so that you can set them in the Designer.

There's no way I know of to do it with the vanilla Panel supplied by
the Framework.
 
Back
Top