Category / Section
Customizing Appearance on Rendering with using NodeCollectionChange Events
1 min 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 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