Hi Klaudiusz,
Thanks for your interest in Syncfusion products.
Yes, it is possible to add/remove/change items in the
diagram’s default context menu. You can get the items in the default context
menu either by its ‘Index’ or through its ‘Text’. Please refer the below code
snippet to add/remove items from the default context menu.
Here is the code:
[C#]
//Add new item to the context
menu.
private void button1_Click(object
sender, EventArgs e)
{
ToolStripSeparator
separator = new ToolStripSeparator();
CustomNode = new ToolStripMenuItem();
CustomNode.Text = "CustomNode";
CustomNode.Click += new EventHandler(CustomNode_Click);
//Adding
new item to the default contextMenu
ToolStripMenuItem
shapeItem = cxtMenu.Items[4] as ToolStripMenuItem;
shapeItem.DropDownItems.Add(separator);
shapeItem.DropDownItems.Add(CustomNode);
}
//Removes the item “Rectangle”
from the context menu.
private void button2_Click(object
sender, EventArgs e)
{
for
(int i = 0; i <
diagram1.ContextMenuStrip.Items.Count; i++)
{
if
(!(diagram1.ContextMenuStrip.Items[i] is ToolStripSeparator))
{
ToolStripMenuItem
item = diagram1.ContextMenuStrip.Items[i] as ToolStripMenuItem;
if
(item.Text == "Rectangle")
{
diagram1.ContextMenuStrip.Items.Remove(item);
break;
}
else
if (item.DropDownItems.Count > 0)
{
for (int j = 0; j <
item.DropDownItems.Count; j++)
{
if (item.DropDownItems[j].Text == "Rectangle")
{
item.DropDownItems.RemoveAt(j);
break;
}
}
}
}
}
}
Here is the sample:
F104404.zip
Please let us know if you have any queries.
Regards,
Amsath Ali. M