Articles in this section
Category / Section

Updating the Image or currently clicked Node as a Cursor using Diagram Control

4 mins read

Cursor changed to Selected Node image

In diagram control, we have built-in support to create the cursor as the currently selected/clicked node shape by using Syncfusion.Windows.Forms.Diagram.ImageCursor’s CreateCursor() method. 

The following code illustrates how to change the cursor to the node’s image while selecting/clicking the node in PaletteGroupBar.

[C#]

private void paletteGroupBar1_NodeDoubleClick(object sender, NodeEventArgs evtArgs)
{
    // Get the index of the node currently clicked in the palette
    int index = paletteGroupBar1.CurrentSymbolPalette.Nodes.IndexOf(evtArgs.Node as Node);
    // Get the image of the node
    Bitmap image = paletteGroupBar1.CurrentSymbolPalette.LargeImageList.Images[index] as Bitmap;
    // Activating the customized tool
    diagram1.Controller.ActivateTool("CustomRectangleTool");
    // Change the cursor to an image
    diagram1.Controller.ActiveTool.ActionCursor = ImageCursor.CreateCursor(image, 40, 40);
}  

 

[VB]

'Registering the events
paletteGroupBar1.NodeDoubleClick += paletteGroupBar1_NodeDoubleClick
 
Private Sub paletteGroupBar1_NodeDoubleClick(ByVal sender As Object, ByVal evtArgs As NodeEventArgs)
 
'Get the index of the node currently clicked in palette
Dim index As Integer = paletteGroupBar1.CurrentSymbolPalette.Nodes.IndexOf(TryCast(evtArgs.Node, Node))
'Get the image of the node 
Dim image As Bitmap = TryCast(paletteGroupBar1.CurrentSymbolPalette.LargeImageList.Images(index), Bitmap)
'Activating the customized tool
diagram1.Controller.ActivateTool("CustomRectangleTool")
'change the cursor as an image
diagram1.Controller.ActiveTool.ActionCursor = ImageCursor.CreateCursor(image, 40, 40)
End Sub
 

 

Conclusion

I hope you enjoyed learning about updating the image or currently clicked node as a cursor using Diagram Control.

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