Solved

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

Posted on 2006-11-01
4
1,047 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now