)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Create/Open the SubDiagram using NodeClick Events

Platform: WinForms |
Control: Diagram |
Published Date: February 9, 2017 |
Last Revised Date: May 31, 2019

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 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
 

 

Sample:

Sample

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon