简体   繁体   中英

resize forms based on controls visibility

I am working on .net win forms application. I have three controls which are placed in a form. These controls are visible based on a condition. When these controls are made invisible I am seeing a blank space on the bottom of the form. I wanted to eliminate the blank space when the control is not visible and the form size should automatically resize when the control is visible. What options/settings/code should I be using?

Here is an example of someone who's using panels from here

private void panel3_VisibleChanged(object sender, EventArgs e)  
{  
if (panel3.Visible == false)  
{  
if (panel3.Tag == null)  
panel3.Tag = panel3.Height;  
panel2.Height += (int)panel3.Tag;  
}  
else 
{  
if (panel3.Tag == null)  
panel3.Tag = panel3.Height;  
panel2.Height -= (int)panel3.Tag;  
}  
}  

If you're using just a form you could use the Form.size property

form1.Size = New Size(150, 200)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM