Re: Form inheritance problems with anchored components

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Miha Markic [MVP C#] (miha)
Date: 05/14/04


Date: Fri, 14 May 2004 16:37:23 +0200

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.

-- 
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
"Junkguy" <junkguy@columbus.rr.com> wrote in message
news:junkguy-812FF8.09534014052004@news-server-fe-02.columbus.rr.com...
>
> 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!
>
> -- 
> Junkguy

Quantcast