简体   繁体   English

Winforms工具栏上的按钮环绕。

[英]Winforms toolbar of buttons wrapping .

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. 关于如何执行此操作有任何建议吗?

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. 然后,将大小更改为普通ToolStrip或其他所需高度的两倍。

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

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

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