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

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

Platform: WinForms |
Control: Diagram |
Published Date: August 23, 2017 |
Last Revised Date: May 31, 2019

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
 

 

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.

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