Create/Open the WinForms SubDiagram using NodeClick Events.
Create/Open the SubDiagram using NodeClick Events
We don’t have built-in option to create/open a new sub-diagram. But we can achieve this requirement of opening the sub-diagram in application level. In this document, we are giving an example to create and open the sub-diagram in another diagram’s model using WinForm Diagram’s NodeClick event.
The following code example for registering the NodeClick event to diagram’s controller
[C#]
//Registering the nodeclick event diagram1.EventSink.NodeClick += EventSink_NodeClick;
[VB]
'Registering the nodeclick event diagram1.EventSink.NodeClick += EventSink_NodeClick
The following code example for create/open the sub diagram using NodeClick event
[C#]
void EventSink_NodeClick(NodeMouseEventArgs evtArgs) { //load the saved diagram file to subdiagram that we want to open if (evtArgs.Node.Name == "Venn Diagram") { subDiagram = diagram3; subDiagram.Load("..//..//Venn Diagram.edd"); } else { subDiagram = diagram2; subDiagram.Load("..//..//StateDiagram.edd"); } if (subDiagram != null) { //assign the current node's location to the subdiagram location subDiagram.Location = new Point((int)evtArgs.Node.BoundingRectangle.X, (int)evtArgs.Node.BoundingRectangle.Y); //show the sub diagram subDiagram.Show(); //setting the diagram bound as total bounds of the content SizeF modelsize = subDiagram.Controller.GetBoundingRect(subDiagram.Model.Nodes, MeasureUnits.Pixel).Size; subDiagram.Size = new Size((int)modelsize.Width, (int)modelsize.Height); } }
[VB]
Private Sub EventSink_NodeClick(ByVal evtArgs As NodeMouseEventArgs) 'load the saved diagram file to subdiagram that we want to open If evtArgs.Node.Name = "Venn Diagram" Then subDiagram = diagram3 subDiagram.Load("..//..//Venn Diagram.edd") Else subDiagram = diagram2 subDiagram.Load("..//..//StateDiagram.edd") End If If subDiagram IsNot Nothing Then 'assign the current node's location to the subdiagram location subDiagram.Location = New Point(CInt(Fix(evtArgs.Node.BoundingRectangle.X)), CInt(Fix(evtArgs.Node.BoundingRectangle.Y))) 'show the sub diagram subDiagram.Show() 'setting the diagram bound as total bounds of the content Dim modelsize As SizeF = subDiagram.Controller.GetBoundingRect(subDiagram.Model.Nodes, MeasureUnits.Pixel).Size subDiagram.Size = New Size(CInt(Fix(modelsize.Width)), CInt(Fix(modelsize.Height))) End If End Sub
I hope you enjoyed learning about how to create/open the WinForms SubDiagram using NodeClick Events.
You can refer to our WinForms Diagram feature tour page
to know 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!