在Windows窗体应用程序上对接和锚定 [英] Docking and Anchoring on a Windows Form application

查看:156
本文介绍了在Windows窗体应用程序上对接和锚定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 C# .NET Compact Framework 2.0 SP2 Windows Mobile 5.0 及更高版本开发应用.

I'm developing an app for Windows Mobile 5.0 and above, with C# and .NET Compact Framework 2.0 SP2.

我有一个WinForm,里面有两个面板(upperPanel和bottomPanel).我希望upperPanel始终填充表单高度的2/3,而bottomPanel填充表单高度的1/3.这两个面板将完全填写表格的宽度.

I have a WinForm with two panels inside (upperPanel and bottomPanel). I want that upperPanel always fill 2/3 of form's height, and bottomPanel fills 1/3 of form's height. Both panels will fill completly form's width.

我用过这个:

upperPanel.Dock = Fill;
bottomPanel.Dock = Bottom;

但是upperPanel完全填写了表单.

But upperPanel fills the form completly.

我该怎么做?我想或多或少地在不同外形尺寸风景 protrait 模式下使用相同的gui.

How can I do this? I want, more o less, the same gui on differents form factors and on landscape or protrait mode.

谢谢.

推荐答案

您需要做的是首先将底部面板放在其上,并将其Dock属性设置为Bottom.然后将面板的高度设置为表单高度的1/3.最后,添加第二个面板并将其Dock属性设置为Fill.这里的关键是您要添加将填充最后要添加的剩余区域的控件.另外,您可以在Visual Studio中使用移至最前"和发送至后退"命令,以使设计人员进行合作.

What you need to do is to put the bottom panel on first and set its Dock property to Bottom. Then set the panel's height to be 1/3 of the form's height. Finally, add a second panel and set its Dock property to Fill. The key here is that you want to add the control that will fill the remaining area to be added last. Alternatively, you can play around with the Bring to Front and Send to Back commands in Visual Studio to get the designer to cooperate.

您可能还需要钩住表单的OnSizeChanged事件,并重新设置底部面板的高度以考虑布局更改.自从我进行紧凑的框架编程以来已经有一段时间了,所以我不确定.

You may also need to hook the OnSizeChanged event for the form and re-set the height of the bottom panel to account for layout changes. It's been a little while since I did compact framework programming, so I'm not sure.

这篇关于在Windows窗体应用程序上对接和锚定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆