Reputation: 51
I have an.exe and I need to collapse a group_box when it is not used and want to expand when a button is clicked.
As of now, I have created a group-box and its been disabled and if a button is clicked that will be enabled and now I want to change the current process that is instead of disabling I want to collapse and instead of enabling I want to expand that group_box.
As of now, for the page load:
groupboxname.enabled=false;
Button click:
groupboxname.enabled=true;
Upvotes: 0
Views: 694
Reputation: 37
You Can Also Try Something Like This For Collapse And Expand The groupbox.
public partial class Form1 : Form
{
int height, width;
bool IsFirstClick = false;
public Form1()
{
InitializeComponent();
height = groupBox1.Height;
width = groupBox1.Width;
groupBox1.Height = 0;
groupBox1.Width = 0;
}
private void button1_Click(object sender, EventArgs e)
{
if (!IsFirstClick)
{
IsFirstClick = true;
groupBox1.Width = width;
for (int i = 0; i < height; i++)
{
groupBox1.Height = i;
}
}
else
{
IsFirstClick = false;
for (int i = height; i>0; i--)
{
groupBox1.Height = i;
}
groupBox1.Width = 0;
}
}
}
Upvotes: 1