MenuStrip控件可以将其LayoutStyle设置为StackWithOverflow吗? [英] Can a MenuStrip control have its LayoutStyle set to StackWithOverflow?
问题描述
我用MenuStrip创建一个简单的表单. MenuStrip的LayoutStyle
设置为HorizontalStackWithOverflow
(默认值).
I create a simple form with a MenuStrip. The MenuStrip's LayoutStyle
is set to HorizontalStackWithOverflow
(the default).
根据 MenuStrip上的MSDN参考,其
According to the MSDN reference on MenuStrip, its LayoutStyle property is inherited from ToolStrip. One of the possible values for the LayoutStyle is HorizontalStackWithOverflow
which is also the default setting. This setting should provide items with its Overflow
property set to AsNeeded are moved to an overflow button.
当我运行应用程序并调整表单大小以便菜单不能完全适合时,这不会发生.我已经将我的ToolStripMenuItems Overflow属性设置为AsNeeded,但是当我调整表单大小时,右边的菜单项就消失了.
When I run the application and resize the form so the menu won't fit completely, this doesn't happen. I've set my ToolStripMenuItems Overflow property to AsNeeded, but when I resize the form, the menu items on the right just disappear.
文档是否不正确,您只能在ToolStrip上获得一个溢出按钮,而在MenuStrip上却没有?还是我需要做其他事情才能使事情正常进行?还是我只是误读了文档?
Is the documentation wrong and can you only get an overflowbutton on a ToolStrip and not on a MenuStrip? Or is there something else I have to do in order to get things working? Or am I just misreading the documentation?
推荐答案
我只是遇到了同样的问题,并且找到了使它正常工作的方法.
I just had the same problem, and found a way to get it working.
在MenuStrip上,您需要设置:
On the MenuStrip you need to set:
myMenuStrip.CanOverflow = True
默认值为false.
然后为您需要设置的每个MenuItem:
Then for each MenuItem you need to set:
myToolStripMenuItem.Overflow = ToolStripItemOverflow.AsNeeded
或
myToolStripMenuItem.Overflow = ToolStripItemOverflow.Always
默认值为ToolStripItemOverflow.从不
参考:
这篇关于MenuStrip控件可以将其LayoutStyle设置为StackWithOverflow吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!