Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'd like to know how to resize controls on a form when a window is maximized in C# so that id the form is maximized or strethced the controls will retain there porportion to each other
Posted
Comments
Ron Beyer 20-Dec-13 9:14am    
What UI framework? WinForms, WPF, ASP, GTK?
Adam Zgagacz 20-Dec-13 9:41am    
Are sure you want to do it? It is not good design practice for GUI (at least for 99.99% of cases).

1 solution

If this is WPF, I'd say: "full speed ahead," but, if this is Win Forms:

About 7 days ago, in the context of a Windows Form Application, there was a similar question, and you might find my dialog (in the comments) with the OP, and my posted (outline of a) "solution" useful: [^].

You may also find the discussion on this QA question relevant: [^].

But, I advise you against attempting dynamic re-sizing and re-positioning of Win Form Controls unless absolutely necessary: imho, too much work for too little a return, and a good chance that arbitrary re-sizing will result in a UI that looks terrible.

You can usually get pretty good results using the standard Control properties 'DockStyle, and 'Anchor. And, do you really want to try and scale things like Fonts where they may not look very good at certain point sizes because of the way that "optical size-based hinting" works ?

If the task at hand was to make sure that my Form looked proportionally re-sized in only two cases: "normal" view, and "maximized" view, I would approach that by simply calculating two layouts, and switching them as the Form's SizeChanged Event was triggered.

If you want help with that, just ask.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900