There's nothing directly in the .NET Framework to help with that, so you may
need to write some code to do intelligent resizing. Anchoring and docking
are useful, but once you start having three or more controls in any
direction it can become a mess.
.NET Framework 2.0 includes some useful stuff regarding different layout
models, autosizing, and padding, but that won't help for now.
> Hello
> Does anybody found a good way to keep the ration of all controls on a form
[quoted text clipped - 9 lines]
>
> Thank you
8870 - 17 Feb 2005 12:47 GMT
> There's nothing directly in the .NET Framework to help with that, so you may
> need to write some code to do intelligent resizing. Anchoring and docking
[quoted text clipped - 17 lines]
> >
> > Thank you
Why doesn't the dotnet class library have a system for calculating the
positions and sizes of the GUI elements at runtime, like the layout managers
in java?
Specifying the position and size of the elements in pixels isn't a good
choice for these reasons:
-the program may be used in more than one language. When the length of the
text on labels, buttons etc. changes, it would be fine if the relative
controls could automatically resize.
-a program may allow the user to change the font used for the GUI. Larger
fonts require the GUI elements to resize, otherwise not the entire text will
be visible
-the user resizes the form and the entire space should be distributed
automatically among then controls
-in a DB application it may be useful that based on the user rights some GUI
elements are visible and others not. The space should always be used
efficiently.
-in higly configurable applications the user may be allowed to define which
fields appear on the forms, which containers are on the form, which fields or
other containers they have etc.
A layout manager which calculates the size of the GUI elements would be very
useful for these reasons.
8870 - 17 Feb 2005 12:49 GMT
Why doesn't the dotnet class library have a system for calculating the
positions and sizes of the GUI elements at runtime, like the layout managers
in java?
Specifying the position and size of the elements in pixels isn't a good
choice for these reasons:
-the program may be used in more than one language. When the length of the
text on labels, buttons etc. changes, it would be fine if the relative
controls could automatically resize.
-a program may allow the user to change the font used for the GUI. Larger
fonts require the GUI elements to resize, otherwise not the entire text will
be visible
-the user resizes the form and the entire space should be distributed
automatically among then controls
-in a DB application it may be useful that based on the user rights some GUI
elements are visible and others not. The space should always be used
efficiently.
-in higly configurable applications the user may be allowed to define which
fields appear on the forms, which containers are on the form, which fields or
other containers they have etc.
I hope MSFT recognizes the need for a layout manager in these cases.
Bob Powell [MVP] - 17 Feb 2005 15:49 GMT
Layout is provided for. There are a few examples of writing a layout
manager. See GotDotNet for details.
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsFormLayout.aspx

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Why doesn't the dotnet class library have a system for calculating the
> positions and sizes of the GUI elements at runtime, like the layout
[quoted text clipped - 21 lines]
> other containers they have etc.
> I hope MSFT recognizes the need for a layout manager in these cases.
Bob Powell [MVP] - 17 Feb 2005 15:54 GMT
also...
http://dotnet.jku.at/projects/slm/

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Why doesn't the dotnet class library have a system for calculating the
> positions and sizes of the GUI elements at runtime, like the layout
[quoted text clipped - 21 lines]
> other containers they have etc.
> I hope MSFT recognizes the need for a layout manager in these cases.
8870 - 21 Feb 2005 13:55 GMT
Thank you for the reply
Yes I have seen the examples in the SDK. If I'm not wrong, the built-in
layout system keeps the GIVEN SIZE (in pixels) for the elements with
DockStyle Left, Right, Top and Bottom, and assigns the remaining space for
the element with DockStyle Fill.
The examples found at http://dotnet.jku.at/projects/slm/ go further the
winforms built-in borderlayout system and provide several choices. When the
container is resized, RubberLayout stretches every control (relative to the
initial size) with the same factor, GridLayout divides the available width
and heigth equally among the elements so they have all the same size,
FlowLayout doesn't change the size of the contained controls but only their
positions...
But in all this stuff something is missing: the ability of the single GUI
elements to calculate the space they need, and so the size and positions of
the entire form.
For example, a Button or Label should calculate its size based on its Text
and Font. A container such as a Panel or Form or TabPage should calculate its
size based on the conatained controls and subcontainers and the desired
layout mode...
I (and perhaps others) would like to build a form WITHOUT having to specify
the size of anything in pixels, because giving the size in pixels isn't a
good choice when the font, caption etc can change at runtime.
see also
http://www.windowsforms.net/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=1729
alejandro lapeyre - 21 Feb 2005 18:06 GMT
You want the same features as in a web page?
The windows forms are not designed to support that kind of automatic
resizing.
Keep enough space for your varying captions, use the default font, keep the
focus on your application purpose and wait for the next release.
regards
Alejandro Lapeyre
> Thank you for the reply
> Yes I have seen the examples in the SDK. If I'm not wrong, the built-in
[quoted text clipped - 26 lines]
> see also
> http://www.windowsforms.net/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=1729