Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 477
  • Last Modified:

Context Menu Seperator

Hi,

try to build a context menu. Now I want to add a menu Seperator and dont't know how ?
               
ContextMenu ctm = new ContextMenu();
ctm.MenuItems.Clear();
ctm.MenuItems.Add("View Trend", new EventHandler(this.OnViewMenuClicked));
ctm.MenuItems.Add("Delete", new EventHandler(this.OnDeleteMenuClicked));
     
Thanks for you help
Martin
0
martinmoessner
Asked:
martinmoessner
  • 3
  • 3
1 Solution
 
boethius78Commented:
Use the ToolStripSeparator control and add to the items as in your code.
0
 
boethius78Commented:
Apologies, I forgot to mention that the ToolStripSeparator will only work with a ContextMenuStrip, not a ContextMenu.

Hope this helps,

b
0
 
Bob LearnedCommented:
For ContextMenu, add an menu with '-' as the text.

Bob
0
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.

 
pradeepsudharsanCommented:
private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
            {
                  ContextMenu ctm = new ContextMenu();
                  ctm.MenuItems.Clear();
                  ctm.MenuItems.Add("View Trend");
                  MenuItem sepmenuItem=new MenuItem("-") ;
                  sepmenuItem.Enabled=false;
                  ctm.MenuItems.Add(sepmenuItem);

                  ctm.MenuItems.Add("Delete");
                  ctm.Show(textBox1,new Point(e.X,e.Y));
            }
0
 
Bob LearnedCommented:
Yeah, some people really need their hand held, huh?

Bob
0
 
boethius78Commented:
Whoa, you were right.  If I were you, LearnedOne, I'd be quite annoyed at that.
0
 
Bob LearnedCommented:
I'm not upset, man, it happens all the time ;)

Bob
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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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