固定 Windows 面板尺寸
如何使 Windows 面板固定,以便它显示在应用程序内的固定位置。
我所说的面板是指 System.Windows.Forms.Panel
如果需要更多信息请告诉我,
谢谢
How can i make the Windows Panel Fixed so that it displays at a fixed location within the application.
By Panel i mean System.Windows.Forms.Panel
Let me know if more info is needed
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
0;0 坐标是表单的左上角,您可以将面板定位到您想要的任何位置:
然后您需要检查 锚点属性 指定调整父窗体大小时其行为方式。默认情况下,锚点将为顶部、左侧,这意味着它将始终与顶部边框和左侧边框保持相同的距离。
以编程方式设置锚点:
如果您不熟悉 winforms 锚点,我建议使用按钮(或其他控件)创建一个简单的可调整大小的表单,并在更改按钮的锚点设置时调整表单大小。
The 0;0 coordinate being the top left corner of your form you can locate the panel wherever you want :
You then need to check the anchor property to specify how it will behave when the parent form is resized. By default the anchor will be Top, Left, meaning it will always stay at the same distance from the top border and from the left border.
To set anchors programmatically :
If you are unfamiliar with winforms anchors I recommend creating a simple resizeable form with a button (or other control) and play around resizing the form while changing the button's anchor settings.
如果您想修复 winform 中面板的位置和大小,尽管父窗口处于最小化或最大化模式,则使用
如果您想将面板保留在某个固定位置,则将面板属性设置为跟随
锚点...顶部,左侧选择自动调整大小....错误。
在面板属性中使用这些属性。
If you want to fix the location and size of panel in winform despite of Minimize or Maximizes mode of your parent windows then use
If you want to keep your panel at some fixed location then set panel property as follow
anchor ... top, left selected autosize....false.
use these properties in panel property.
默认情况下,Panel 控件始终位于固定的顶部、左侧位置,就像所有 Windows 窗体控件一样。
By default the Panel control is always at a fixed top,left location as indeed are all windows forms controls.