简体   繁体   English

将控件停靠到WinForms中的其他控件上

[英]Dock control to other one in WinForms

I have got MainForm with TabPage. 我已经有了Tab的MainForm。 On TabPage i have got three groupboxes next to one another. 在TabPage上,我有三个彼此相邻的分组框。 First is docked to left top, third to right top. 首先停靠在左上方,第三停靠在右上方。 everything is ok but if i maximize window , center textbox goes to bad position (is hide behing first groupbox) How dock this one to stay always between first and third groupbox? 一切都很好,但是如果我最大化window,则中心文本框将移至不良位置(正在隐藏第一个groupbox)如何将其停靠在第一个和第三个groupbox之间?

You can accomplish this by using the Dock properties OR the anchor properties. 您可以通过使用Dock属性或anchor属性来完成此操作。 Adding the groups boxes so they are ordered left to right: 添加组框,使它们从左到右排序:

Using the Dock properties: 使用Dock属性:

`groupBox1.Dock = left`
`groupBox3.Dock = right`
`groupbox2.Dock = center`

Using the Anchor properties: 使用锚属性:

`groupBox1.Anchor = Top, Left`
`groupBox3.Anchor = Top, Right`
`groupbox2.Anchor = Top, Left, Right`

EDIT: In either case the center groupBox (groupBox2) should adjust to fill the space between the two outer groupboxes (groupBox1 and groupBox3) 编辑:在两种情况下,中心groupBox(groupBox2)都应进行调整以填充两个外部groupbox(groupBox1和groupBox3)之间的空间

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

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