Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello frnds,

In my project, i have 2 groupboxes. Based on some condition i have to make 1stgroupbox.Visible = false
Now, i want that the 2ndgroupbox (which was under it) should take the 1stGroupbox's place.
How can i do so?
On doing some research, i found that if i use TableLayoutPanel and play with the row AutoSize property, then i can achieve it.
Just wanted to check, are there any other ways to do this.

I dont want to use TableLayoutPanel becoz then i need to make a separate panel or usercontrol to put all the groupboxcontrols in them.

Please suggest.
thanks.
Posted
Comments
Ralf Meier 29-Jun-15 3:37am    
The Location of Groupbox1 is different to GroupBox2 ?
Does the Size from GroupBox1 has to grow up when it becomes Visible ? Or should it shrink ?

Your first GroupBox is invisible, but does still exist. You can access its properties:
C#
groupBox1.Visible = false;
groupBox2.Location = groupBox1.Location;
groupBox2.Size = groupBox1.Size;
groupBox2.Visible = true;
 
Share this answer
 
For someone who needs the solution for similar problem:
Add TableLayoutPanel and then add your controls to each row of the table. Set the AutoSize property of table's row & column to true.
Worked for me.
 
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