Articles in this section

Is it possible to have the context menu by right clicking the node?

 

Display context menu on a selected Node

It is possible to display a context menu on a selected node. To display the context menu on the selected node and add it to new nodes, the following JavaScript should be used.

// To display the context menu
function attachevent()
{
document.getElementById('DiagramWebControl1').oncontextmenu=function()
{
PosX = ConvertXYToDocument(Diagram.GetRootElement(), event.clientX, event.clientY, Diagram.GetMagnification()).x;
PosY = ConvertXYToDocument(Diagram.GetRootElement(), event.clientX, event.clientY, Diagram.GetMagnification()).y;
Popup.ShowPopup(event.clientX, event.clientY);
return false;
};
}
function OnContextMenuClick(Obj)
{
if (Obj.Text != "Edit")
{
Diagram.Refresh(Obj.Text + "|" + PosX + "|" + PosY);
}
else if (IsNodeSelected)
{
alert("Not implemented");
}
else
{
alert("Please select a Node to Edit");
}
return false;
}

 

Conclusion

I hope you enjoyed learning about whether it is possible to have the context menu by right-clicking the node.

You can refer to WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied