Articles in this section
Category / Section

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

1 min read

Cursor changed to Selected Node image

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

The following code illustrated to change cursor as Node’s image while select/clicking the node in PaletteGroupBar.

[C#]

//Registering the events
paletteGroupBar1.NodeDoubleClick += paletteGroupBar1_NodeDoubleClick;
 
private void paletteGroupBar1_NodeDoubleClick(object sender, NodeEventArgs evtArgs)
{
//Get the index of the node currently clicked in 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 as 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
 

 

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