Solved

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

Posted on 2006-11-01
4
1,053 Views
Last Modified: 2012-06-27

Thanks.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17854042
You just add a tool bar button but set its style to separator :

this.toolBarButton.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
0
 

Author Comment

by:lapucca
ID: 17859866
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
 

Author Comment

by:lapucca
ID: 17861544
I'm referring to the text menu part not the menustrip that contains the icon buttons.  Thanks.
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17861628
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question