Problems with inheriting from a windows form

G

Guest

Hi,

I have a base form from which i want all of my forms to inherit from. The
base form has three buttons anchored to the bottom right of the base form.
When i first inherit a new form from the base form everything seems to be
fine. The 3 buttons from the base form show up on the bottom right of the
inherited form. But as i started adding new controls and building it i found
that the 3 buttons from the base form disappeared. When i expanded the
inheriting form and rebuilt it the 3 buttons showed up but in a wrong
location. And as i play around with resizing the inheriting form the 3
buttons seems to appear and disappear erratically. I rebuilt the solution
everytime. The same control location appear even when i run the app. I am
using VS.NET 2005. Has anybody encountered this problem before? Am i doing
anything wrong or miss anything or is it just a problem with the IDE? Any
help on this issue will be greatly appreciated.

Thank You,
Vish
 
G

Guest

Hi,

Yes, I sure did set the anchor property of the 3 buttons to "Bottom Right".
When i inherit a new form it comes up alright. It is after i start adding
controls to it that the behaviour becomes erratic.

Thank you,
Vish
 
B

Bruce Wood

Odd. I've never had that problem.

Are the buttons "private" in the parent form? Remember that even with
Anchor set to "Bottom Right", the child form still has to set the
Location properties of the buttons if you resize the child, and it
can't do that if the buttons are "private". Try setting the buttons'
visibility to "protected" on the parent form and see if that fixes the
problem.
 
G

Guest

Hi Bruce,

Seems like setting the modifiers to protected fixed the problem atleast for
the new inheriting forms. I greatly appreciate your help.

Thank You,
Vish
 
N

Nick Hounsome

Glad you've got it sorted.

I would also suggest that unless you want to add other buttons in the same
row the proper way to do this is to put them in a panel and dock the panel
to the bottom - I SUSPECT that this would solve your problems without
requiring protected fields.
 
B

Bruce Wood

Yes, it would. That's a better solution, I agree.

Docked objects don't need to be protected in the parent, since the
child never needs to modify their location or size. Objects placed
directly on the parent form that are Anchored other than Top Right need
to be protected, because the child form needs to modify at least their
Location, if not their Size, as it is resized.
 
G

Guest

Thanks for the suggestion guys. I would like the buttons to be private since
the inheriting forms should not modify the buuton property. Panel seems to be
be a good way to go. I wanted to get your thoughts on using a
toolstripcontainer instead of a panel. Do you think it is appropriate or is
it overkill? I do anticipate adding another dropdownbutton to the "Bottom
Left" for "Options" like printing etc.

-Vish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top