Row Items Separator in ContextMenu

  • Thread starter Thread starter Luigi Z
  • Start date Start date
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.
 
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
 
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
 
Back
Top