Resizing windows and controls

C

Chris

Hi,

In design mode I built some windows with some controls (e.g.
listboxes, labels, chgeck boxes etc.) in it, and I did set
the property for the window size is set to normal.

Now, when I run my app the first user's action is to
maximize the window, but the controls inside the window are
not resized simultaneously with my window, resulting in a
real meshy window.

Of course, I read something about *anchoring*, but I don't
hope I need to anchor all (20) my controls for pretty
resizing.

So, is there an easy way to do this, maybe by setting a
single window property.

Some help would be nice.

Thanks,
Chris
 
S

Stefan Kiryazov

I haven't heard of such. Better read more about anchoring and docking -
you'll see it's not such a heavy burden.
 
A

Ahmed Qurashi

For complex apps you really can't get out of rolling your own Layout Engine.

As an example, see one of the third party solutions such as SandDock for
controls or SandBar for toolbars:
http://www.divil.co.uk/net/

For simple apps, why not just employ a Fixed (unresizable) window?

myForm.FormBorderStyle = FormBorderStyle.Fixed3D;

ok,
aq
 
R

Ranjan

I dont agree to this. My experience with complex apps, basically complex
forms and 3rd party Resizers has been pathetic. I would suggest you get on
with the good habit of anchoring, docking controls. You should use panels
for this, and then resize. If the forms are quite simple though, you can use
3rd party resizers, like XSizer etc.

Ranjan
 
C

Chris

For simple apps, why not just employ a Fixed (unresizable)
window?

The problem is that in design mode you can't design a full
screen window, as it does not fit in the proper window in
Visual Studio .NET. So, you design a window of moderate
size with the all controls in it, and then at runtime the
user will maximize it for better visibility.

I remember for other GUI designers (XVT designer) that you
did not have to do anything to get this behaviour. It was
the default behaviour. Imho resizing a window MUST always
result in resizing all controls in it.
I can hardly imagine why you would NOT want this behaviour
.....

Chris.
 
R

Ranjan

Chris,
There are some cases where the font size will become an issue when
the size controls grow. Its hard to explain, its not logical but aesthetic
:)
 
B

Bruce Wood

I can easily imagine why you would not want this behaviour. To see why,
ask yourself, what does "resizing all controls" mean?

Does it mean that every control gets bigger or smaller according to the
new window size, so everything scales proportionally? Or does it mean
that the controls move with the new window boundaries, while one
principal control (such as a list view or data grid) expands to fill
the remaining space? Or does it mean that most controls follow the
window boundary while two or three controls share the remaining space
evenly? All of these are reasonable designs for what to do when a
window changes shape, which is exactly why the .NET Framework doesn't
provide a default. You have to decide what happens and design the form
accordingly.

I have to admit that for me this wasn't too difficult, as I came from
the Java world in which you have to supply layout managers with your
forms. .NET is a bit more tedious (although I hear that they are
introducing more powerful layout classes in V2.0). For now you have to
use docking and anchoring, and place controls within panels within
panels to get nice resizing behaviour. It's really not that much work:
it's all drag and drop and setting properties in the forms designer.

However, no, there is no "make this form pretty" flag, because the
definition of "pretty" is different for every application.
 
A

Ahmed Qurashi

Perhaps intuitively the default would scale all controls when the form is
resized but for WinForms 1.0 the default is the Fixed or Grid style. There
is no flow.

I think the original intention was to provide a high degree of extensibility
within the framework. Of course that requires handling all the events that
can alter controls, not just user interaction but also content change, etc.
So the short answer is there is no magic "makepretty" switch, but building a
custom layout engine that uses anchoring, docking and event handlers to get
what you want isn't so dificile either:
http://windowsforms.net/articles/customlayoutengines.aspx

In Avalon, with scalable vector based graphics, there is something I've seen
referred to as Dynamic Flow. When a resize event occurs, controls can scale
and re-dock automatically. Layout is handled through the form rendering
engine. It's still in Preview, unfortunately:
http://www.microsoft.com/downloads/...E1-B4CA-402B-ACCF-AAA2BD60DA74&displaylang=en

ok,
aq
 
Q

qwerty

Try reading up on Control's Anchor and Docking properies. Use these
two properties in combination with panel and you get a powerfull way
of laying out ur control. I made some pretty complex form with lots of
controls just by using panels and that two properties. Remember, you
can put one panel inside the other.
 

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