C# 在 MenuStrip 中添加水平分隔符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/504598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding a horizontal separator in a MenuStrip
提问by Malfist
I can't seem to find any way to add a horizontal separator in a MenuStrip. Visual Studio complains Cannot add ToolStropSeparator to MenuStrip.
我似乎找不到在 MenuStrip 中添加水平分隔符的任何方法。Visual Studio 抱怨无法将 ToolStropSeparator 添加到 MenuStrip。
Any idea's how I can do this?
知道我该怎么做吗?
采纳答案by GWLlosa
I'm able to run code like this:
我能够运行这样的代码:
this.menuMain.Items.Add(new ToolStripSeparator());
without any trouble... What kind of error are you getting?
没有任何麻烦......你遇到了什么样的错误?
回答by Gerard
In the space between the two fields you want separated by the divider, type:
在要由分隔符分隔的两个字段之间的空间中,键入:
-
then hit enter (in the designer)
然后按回车键(在设计器中)
回答by WhySoSerious
You can right-click the menustrip, then 'Insert' -> 'Separator'. That's all.
您可以右键单击菜单条,然后“插入”->“分隔符”。就这样。
回答by Mojtaba
- Add The MenuStrip to Form
- Click MenuStrip And Click Items "..." In Properties Window
- In Opened Window in Section "Select item and add to list below" Click Add
For Example For 3 Then Select the for example toolStripMenuItem1 and Click DropDownItems "..." Then in Section to New Opened Window "Select item and add to list below" Select Separator | And Add it. Good Lock
- 将 MenuStrip 添加到表单
- 单击 MenuStrip 并单击属性窗口中的项目“...”
- 在“选择项目并添加到下面的列表”部分的打开窗口中,单击添加
例如 3 然后选择例如 toolStripMenuItem1 并单击 DropDownItems“...” 然后在新打开的窗口部分“选择项目并添加到下面的列表”选择分隔符 | 并添加它。好锁
回答by verena
steps: 1. right click on contextmenuStrip items - > Insert -> Separator
步骤: 1.右键单击contextmenuStrip项目->插入->分隔符
OR
或者
a) Click on (Type Text box for ContextMenuStrip) where you want to put the horizontal separator, then enter" - "(Minus sign) b) Enter hope this will find you useful :)
a) 单击(为 ContextMenuStrip 键入文本框)要放置水平分隔符的位置,然后输入“-”(减号)b)输入希望这对您有用:)
回答by Coder_4_Life
I like to do mine with - rather then a separator. So say i wanna make a horizontal separator i would do about 30 of them to create a horizontal dotted line with a length of 30. Then i would set its enabled property to false so it can't be clicked as for a vertical one. Just do | then your item for each item and you will notice it will create a vertical line matching up with each item. [Note] The vertical line will be dotted due to the spacing between each item.
我喜欢用 - 而不是分隔符来做我的。所以说我想做一个水平分隔符,我会做大约 30 个来创建一个长度为 30 的水平虚线。然后我将它的 enabled 属性设置为 false,这样它就不能像垂直的那样被点击。只是做| 然后你的每个项目的项目,你会注意到它会创建一个与每个项目匹配的垂直线。【注意】垂直线会因每一项之间的间距而被打上虚线。
回答by Aravindi Amarasinghe
It' so simple,
太简单了
Right click on the Context menu strip icon. then Select insert and after select Separator |
右键单击上下文菜单条图标。然后选择插入,然后选择分隔符 |
回答by dave88
There are no separators for menu strip items.
菜单条项没有分隔符。
However;
然而;
You can select the item you want a space between, and set the left or right margin value. This works just as well.
您可以选择要在其间留出空格的项目,并设置左边距或右边距值。这也同样有效。