Solved

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

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

Thanks.
0
Comment
Question by:lapucca
  • 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: 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.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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