Winforms 工具栏的按钮换行。

发布于 2024-07-06 12:36:20 字数 133 浏览 4 评论 0原文

我动态地向工具栏添加了一堆按钮。 如果按钮数量超过当前表单中的水平空间,我希望能够以编程方式将其换行到第二行。 我不希望用户必须单击下拉按钮才能查看更多按钮,因为我需要确保所有按钮始终可见。

对于如何做到这一点有什么建议吗?

I am dynamically added a bunch of buttons to a toolbar. I want the ability to programatically make it wrap onto a second row if the number of buttons exceeds the horizontal space in the current form. I dont want users to have to click the dropdown button to view more buttons as i need to ensure that all buttons are viewable always.

are there any suggestions for how to do this.

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

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

发布评论

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

评论(1

紅太極 2024-07-13 12:36:20

你只需要四行。 首先,禁用停靠:

Me.ToolStrip1.Dock = System.Windows.Forms.DockStyle.None

然后关闭自动调整大小:

Me.ToolStrip1.AutoSize = False

现在将布局设置为“Flow”

Me.ToolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow

然后将大小更改为普通 ToolStrip 高度的两倍,或任何您想要的。

Me.ToolStrip1.Size = New System.Drawing.Size(300, 50)

You need just four lines. First, disable docking:

Me.ToolStrip1.Dock = System.Windows.Forms.DockStyle.None

Then turn off auto-sizing:

Me.ToolStrip1.AutoSize = False

Now set the layout to "Flow"

Me.ToolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow

Then then change the size to double the height of a normal ToolStrip, or whatever you want.

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