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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Customizing Appearance on Rendering with using NodeCollectionChange Events

Platform: WinForms |
Control: Diagram |
Published Date: December 15, 2015 |
Last Revised Date: May 31, 2019

Customizing Appearance on Rendering while using NodeCollectionChanged Events

Syncfusion Diagram supports customizing the appearance of the node using the NodeCollectionChanged events. Using the NodeCollectionChanged events the node can be customized.

The below code shows how to customize the appearance of the node.

[C#]

// Registering NodeCollectionChanged Event
diagram2.EventSink.NodeCollectionChanged += EventSink_NodeCollectionChanged;
 
// Customizing the Appearance of the node
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
        {
            if (evtArgs.Elements is NodeCollection || evtArgs.Element is Node)
            {
                if (evtArgs.Elements is NodeCollection)
                {
                    NodeCollection NodeColl = (NodeCollection)evtArgs.Elements;
                    foreach (Node N in NodeColl)
                    {
                       // Customizing Nodes Line Color and width
                        N.LineStyle.LineColor = Color.Red;
                        N.LineStyle.LineWidth = 2;
                    }
                }
                else
                {
                    Node Nod = (Node)evtArgs.Element;
                    Nod.LineStyle.LineColor = Color.Red;
                    Nod.LineStyle.LineWidth = 2;
                }
            }
        }

[VB]

' Registering NodeCollectionChanged Event
Private diagram2.EventSink.NodeCollectionChanged += AddressOf EventSink_NodeCollectionChanged
 
' Customizing the Appearance of the node
Private Sub EventSink_NodeCollectionChanged(ByVal evtArgs As CollectionExEventArgs)
   If TypeOf evtArgs.Elements Is NodeCollection OrElse TypeOf evtArgs.Element Is Node Then
    If TypeOf evtArgs.Elements Is NodeCollection Then
     Dim NodeColl As NodeCollection = CType(evtArgs.Elements, NodeCollection)
     For Each N As Node In NodeColl
        ' Customizing Nodes Line Color and width
      N.LineStyle.LineColor = Color.Red
      N.LineStyle.LineWidth = 2
     Next N
    Else
     Dim Nod As Node = CType(evtArgs.Element, Node)
     Nod.LineStyle.LineColor = Color.Red
     Nod.LineStyle.LineWidth = 2
    End If
   End If
End Sub

 

 

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