Articles in this section
Category / Section

Customizing Appearance on Rendering with using NodeCollectionChange Events

3 mins read

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 Node's 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 Node's 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

 

Conclusion

I hope you enjoyed learning about customizing appearance on rendering while using NodeCollectionChanged events.

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)
Please  to leave a comment
Access denied
Access denied