Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody!

I am working with a window application in c# 4.0. I have a page which have multiple group boxes which are by default invisible.

And only one group box will be visible at a time and another will be remain invisible.
So i want to set the size of form automatically adjust according to the size of single group box.

I have been set the AutoSize = true and AutoSizeMode = growAndShrink but still my page's size not displaying properly.

How i can set this, if anybody have any suggestion then please tell me thanks in advance.

Regards..
dEV kASHYAP
Posted
Updated 9-Jan-12 23:15pm
v2

Usually it's not a good GUI design to change the size of the window dynamically.
I suggest to add all GB one over another and size the window for the bigger one.

In editor use right-click and "Select xyz" to access GB you want (it will be brought to front - in designer only).
 
Share this answer
 
set Top property for controls

ex.

C#
GroupBox1.Top=200;
 
Share this answer
 
try by this..

C#
this.Height += groupbox1.Height + 10;
this.Width += groupbox1.Width + 10;


hope it works..
 
Share this answer
 
As suggested by Catalin, it is bad practice to resize the UI automatically on a user as the work with your application.
Your UI should be built to be resizable by the user with a fixed minimum size. Set the minimum size of your form to the size required to show the larger of your group box controls. Either resize the elements in your smaller group box or just resize the group box itself to match the size and location of the larger group box. Now when you toggle the visiblity of the group boxes, you don't have to worry about the resizing. If you don't want the user to make any changes to the size of the application on their own, it is acceptable to disable form resizing.
 
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