在 Windows 窗体设计器中将控件与窗体中心对齐

发布于 2024-08-12 19:03:13 字数 60 浏览 7 评论 0原文

这是一直让我烦恼的事情:如何让 Windows 窗体设计器为我正在处理的窗体的水平和垂直中心提供像素捕捉?

This is something that's been driving me up the wall: how can I get the Windows Forms designer to provide pixel snapping for the horizontal and vertical centers of the form I'm working on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可爱暴击 2024-08-19 19:03:13

Visual Studio 提供了许多工具来帮助对齐表单中的控件组并调整其大小。这些功能可使用布局工具栏访问。要显示布局工具栏,请右键单击标准 Visual Studio 工具栏的任何部分,然后从下拉菜单中选择“布局”。生成的工具栏将如下所示:

Visual Studio 布局工具栏
替代文字

选择一组组件,然后单击工具栏中的各个按钮即可查看效果。例如,所有控件都可以左对齐或右对齐,并将大小调整为相同的大小、宽度或高度。还可以均匀地间隔控件,然后增加或减少用于分隔控件的间距。还可以将控件放在另一个控件的顶部并更改显示在堆栈顶部的控件(这也可以在 Visual Basic 代码中使用相应控件的 BringToFront() 和 SendToBack() 方法来完成)。

总而言之,控件的选择允许从表单中的一组控件实现几乎任何统一的布局。

http://www.techotopia.com/index.php/Designing_Forms_in_Visual_Studio< /p>

第 5 个和第 6 个图标从右端开始将为您解决问题:

  • 水平居中 垂直
  • 居中

不太自动,但仍然有效。

Visual Studio provides a number of tools to assist in aligning groups and sizing groups of controls in a form. These features are accessed using the layout toolbar. To display the layout toolbar right click on any part of the standard Visual Studio Toolbar and select Layout from the drop down menu. The resulting toolbar will appear as follows:

The Visual Studio Layout Toolbar
alt text

Select a group of components and click on the various buttons in the toolbar to see the effect. For example, all the controls can be left or right aligned and resized to the same size, width or height. It is also possible to equally space the controls, and then increase or decrease the spacing used to separate the controls. It is also possible place controls on top of one another and change which control appears on top of the stack (this can also be done in Visual Basic code using the BringToFront() and SendToBack() methods of the respective controls).

All together, the selection of controls allows just about any uniform layout to be achieved from a group of controls in a form.

http://www.techotopia.com/index.php/Designing_Forms_in_Visual_Studio

5th and 6th icon from the right end will do the trick for you:

  • Center Horizontally
  • Center Vertically

Not quite automatic, but still works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文