Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2005

Tip: Looking for answers? Try searching our database.

Keep the ration while resizing a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LBS - 17 Dec 2004 21:54 GMT
Hello
Does anybody found a good way to keep the ration of all controls on a form
while resizing it ?
I tried many things with the anchor and dock option but it still come up
pretty ugly as controls end up on top of each others.

A good example of what I would like to see is actually your windows
environment.
By that, I mean the display option in your regional setting.
For instance, if you are working on 800*600, and you switch to 1600*1200,
everything is resize but the ratio is kept.

Thank you
Ed Kaim - 18 Dec 2004 00:21 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
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 

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.