Row Items Separator in ContextMenu

L

Luigi Z

Hi all,
I have a Context Menu Strip in my WinForm (C# 2.0) that is like:

private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add("Add new Voce");
contextMenuStrip1.Items.Add("Delete selected Voce");
}

How is it possible to add, between the "Add new Voce" and "Delete selected
Voce" a row separator (like Windows does)?

Thanks in advance.
 
M

miher

Hi,

You need to add a ToolStripSeparator to the items collection.
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add("Add new Voce");
contextMenuStrip1.Items.Add(new ToolStripSeparator());
contextMenuStrip1.Items.Add("Delete selected Voce");
}


Hope You find this useful.
-Zsolt
 
L

Luigi Z

miher said:
Hi,

You need to add a ToolStripSeparator to the items collection.
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add("Add new Voce");
contextMenuStrip1.Items.Add(new ToolStripSeparator());
contextMenuStrip1.Items.Add("Delete selected Voce");
}


Hope You find this useful.

Perfect, thank you very much Miher.

Luigi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top