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:
Please let us know if you have any queries.
Regards,
Amsath Ali. M
Hi Klaudiusz,
Thanks for your update.
We are happy to hear that the issue has been resolved.
Please let us know if you require any further assistance on
this. We would be happy to help you out.
Regards,
Amsath Ali. M