Vis Form Inheritance weirdness

  • Thread starter Thread starter bill
  • Start date Start date
B

bill

I've got a base form with a few controls on it. I have a subclass that
inherits from the base form and it looks the part.

But when I start dropping controls on a panel (which is anchored to the top
of the form) that's inherited from the base form , the controls appear only
until I save the form. If I close and reopen the descendent form, the
controls are either invisible or have jumped up to the top of the form where
they can't be seen. I can still see their declarations in the form's class
but they're not left where I placed them.

Do I need to do anything such as set the controls in the base class from
Private to Public. What else do I need to look at?

Thanks
-Bill
 
Hi bill,

Have you chaecked to see weather the controls you place onb the inherited
form are not being ordered to the back? I seem to remember having a similar
problem (sorry can't remember how I delt with it).

jodie
 
That's part of it. I can bring them to front but sometimes they move around
as well. Perhaps it has something to do with sizing differences between the
forms? One thing I've noticed is that a panel of buttons I have on the base
form, creeps around to new locations on the subclassed form. Seems to be a
conflict between properties on the base form and the descended form.

Question, do I need to change the class definitions of the controls on my
base class? Should private be changed to public (or something else) for the
base form's controls such as: private System.Windows.Forms.Panel pnlBottom;

-Bill
 
I have recreated the scenario and I see what you mean. I am not sure about
the 'creeping' of the panel.

Yes 'Public WithEvents Panel1 As System.Windows.Forms.Panel' seems to solve
the issue.
Jodie Rapson
 
bill said:
That's part of it. I can bring them to front but sometimes they move around
as well. Perhaps it has something to do with sizing differences between the
forms? One thing I've noticed is that a panel of buttons I have on the base
form, creeps around to new locations on the subclassed form. Seems to be a
conflict between properties on the base form and the descended form.

Question, do I need to change the class definitions of the controls on my
base class? Should private be changed to public (or something else) for the
base form's controls such as: private System.Windows.Forms.Panel
pnlBottom;

I've got problems like this as well. They seem to have to do with anchoring
and/or docking and with differences in the sizes of the base form vs. the
derived form. One thing I saw with anchoring was that when the derived form
was double the width, a button anchored to the right of it in the base form
went way off the screen in the derived form - by about the additional width.

I also had fun with docking, and the problem always turned out to be the
Z-order. Playing around with Bring to Front and Send to Back usually worked,
except that every time I'd load the form in the designer, the dock:fill
controls would all "fill" the size of the base form. Resizing them by 0
fixed things up.
 
Back
Top