当窗口最大化时,如何使控件调整自身的大小?

时间:2022-11-30 19:00:32

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: 当窗口最大化时,如何使控件调整自身的大小?

我似乎搞不清楚。在窗体窗口的左边有两个组框。当窗口正常大小(1000x700)时,两个框是相同的。然而,当窗口最大化时,结果是这样的:

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?

我想要的是“Log”组框和选项卡控件同时延伸到窗口的底部。我尝试过用锚定法,但似乎只是移动它而不是调整它的大小。船坞填满了整个侧面。我有什么选择?

3 个解决方案

#1


32  

Make Log's Anchor property= Top|Left|Bottom. Make tab control's Anchor property = Top|Left|Bottom|Right

使Log的锚属性=顶部|左|底部。使选项卡控件的锚属性=顶部|左侧|底部|右侧

#2


4  

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.

如果你固定在顶部,它会上下移动整个控件。如果锚定到顶部+底部,它会拉伸控件,使其随着表单的增长而增长。

#3


0  

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

您可以更改Max属性,同时更改另一个事件。检查:

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

#1


32  

Make Log's Anchor property= Top|Left|Bottom. Make tab control's Anchor property = Top|Left|Bottom|Right

使Log的锚属性=顶部|左|底部。使选项卡控件的锚属性=顶部|左侧|底部|右侧

#2


4  

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.

如果你固定在顶部,它会上下移动整个控件。如果锚定到顶部+底部,它会拉伸控件,使其随着表单的增长而增长。

#3


0  

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

您可以更改Max属性,同时更改另一个事件。检查:

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