Form inheritance problems with anchored components

J

Junkguy

Hi,

I'm having a problem in Visual Studio in C#, using .NET Framework 1.1 Version
1.1.4322 and Microsoft Development Environment 2003 Version 7.1.3088

I make a form A and subclass it with form B. I place a protected component on
A and anchor it top,left,bottom,right.

If I change the size of form B, component G will resize with it
proportionally. But, when I recompile, the derived component G on form B will
"jump" resizing itself relative to its base class size.

For example, make a form A, size 300x300 and place a group box G on it, sized
200,200. Make G protected and anchor to top,left,bottom right. Now make a
subclass of form A called B.

B will have the G component on it of course. Set the size of form B to
400,400. Naturally G resizes with the form to 300,300. Now build the project
and "sproing!", component G resizes itself to 400,400 and is now over the
right and bottom edges of form B.

Now, reset B and G to their original values by hand in the Properties window.
Rebuild. Set form B to size 250,250. Group box G will resize to 150,150 of
course. Rebuild and "sproing!", component G resizes itself to 100,100.

Needless to say, this is extremely frustrating. I must leave all my subclassed
forms the exact same size as the base class or the components go haywire.
Subclass components placed inside base class components do not change size, so
they end up in wrong places and sizes within the base components, etc.

Has anyone else experienced this same issue. I cannot find anything about this
in the knowledge base. Maybe there is a fix for it, but I can't find it.

Thanks!
 
M

Miha Markic [MVP C#]

Hi

I solve this problem with docking and always anchoring to top or left only.
For example, if I want to have a button in lower right corner anchored to
right I do the following:
Create a panel and dock it to the bottom, within it create a panle and dock
it to the right and on this panel put a button anchored to letf/top only.
Another workaround might be to create your controls with code.

And yes, it is frustrating.
 
J

Junkguy

Miha Markic said:
Hi

I solve this problem with docking and always anchoring to top or left only.
For example, if I want to have a button in lower right corner anchored to
right I do the following:
Create a panel and dock it to the bottom, within it create a panle and dock
it to the right and on this panel put a button anchored to letf/top only.
Another workaround might be to create your controls with code.

And yes, it is frustrating.

Yikes! Are you serious. There is no fix for this?

Thanks for your response though. I appreciate your imagination in this. God
knows you need imagination to deal with the crazy curve balls that Visual
Studio throws your way.
 
M

Miha Markic [MVP C#]

Yikes! Are you serious. There is no fix for this?

AFAIK not.
Thanks for your response though. I appreciate your imagination in this. God
knows you need imagination to deal with the crazy curve balls that Visual
Studio throws your way.

There are not that many afterall, at least serious ones.

Miha
 

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