简体   繁体   中英

How can I make a control resize itself when the window is maximized?

I can't seem to figure this out. I have two group boxes on the left side of my form window. When the window is normal size (1000x700), the two boxes are the same. However, when the window is maximized, it ends up looking like this:http://imgur.com/X2Ou7.png

What I want is for both the "Log" group box and the tab control to extend down to the bottom of the window. I have tried messing with anchoring, but that just seems to move it and not resize it. Docking fills the whole side. What options do I have here?

Make Log's

Anchor property= Top|Left|Bottom.

Make tab control's

Anchor property = Top|Left|Bottom|Right

If you anchor to the top, it'll move the whole control up and down. If you anchor to top+bottom, it'll stretch the control so that it grows as the form grows.

You could change the Max property along with the other event changed. Check this:

private void frm_Resize(object sender, EventArgs e)
{
   if (this.ParentForm.WindowState == FormWindowState.Normal && 
       this.WindowState == FormWindowState.Maximized)
   {
      this.ParentForm.WindowState = FormWindowState.Maximized;
   }
}

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