• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1058
  • Last Modified:

How do I add a ToolStripSeparator on a mainmenu bar programmactically?


Thanks.
0
lapucca
Asked:
lapucca
  • 2
  • 2
1 Solution
 
ozymandiasCommented:
You just add a tool bar button but set its style to separator :

this.toolBarButton.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
0
 
lapuccaAuthor Commented:
Where is the adding part?  Also, how do I specify to insert this infront of the last menuitem which is the Exit.  Thank you.
0
 
lapuccaAuthor Commented:
I'm referring to the text menu part not the menustrip that contains the icon buttons.  Thanks.
0
 
ozymandiasCommented:
Create a MenuItem.
Set its text to "-" and ASdd it to the Menu.

MenuItem menuitem = new MenuItem();
menuitem.Text = "-";
mymenu.Add(menuitem);

If you want it in a particular place then use :

mymenu.Insert(index, menuitem);

where index is the position in the list of existing menu items where you want the separator inserted.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now