简体   繁体   English

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

[英]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.当窗口为正常大小(1000x700)时,两个框是一样的。 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.您可以在更改其他事件的同时更改Max属性。 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;
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当窗口在.net中最大化时,如何调整控件(面板,网格)本身的大小 - how can i make resize to controls(Panel ,Grid) itself when window is maximize in .net 当最大化/最小化时,如何调整TextBox的大小以适应窗口大小? - How do I resize TextBox to fit the Window size when it Maximized/Minimized? 在WPF中最大化窗口时,如何拉伸窗口中的所有内容? - How can I stretch everything in my window when window is maximized in wpf? 当窗口最大化时,ListBox控件未调整大小 - ListBox control not resizing when window is maximized 在用户放开鼠标按钮之前,我可以让窗口不调整大小吗? - Can I make a window not resize itself until the user lets go of the mouse button? Electron.Net:如何在最大化模式下启动 window? - Electron.Net: How can i start a window in maximized mode? 最大化时如何删除控制框 - How to delete control boxes when maximized 当mdiChild最大化时,如何在UltraToolbar中隐藏mdiChild图标? - How can I hide the mdiChild icon in an UltraToolbar when the mdiChild is maximized? DXRibbonWindow 最大化时如何关闭、恢复或最小化它? - How can I close, restore or minimize DXRibbonWindow when it is maximized? 如何允许用户调整窗口大小? - How can I allow a user to resize a window?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM