How to change cursor?

unhandled

#1

I’m developing a custom C# component which has a custom attribute to override the appearance of the component. I’m trying to figure out how to change the mouse cursor when the cursor enters to a specific region, but I couldn’t.
Could somebody advise me please?

public override GH_ObjectResponse RespondToMouseMove(GH_Canvas sender, GH_CanvasMouseEvent e)
{
if (tmprect.Contains(e.CanvasLocation)){
//change cursor
}

        return base.RespondToMouseMove(sender, e);
    }

Thank you.


#2

For GH cursors:
Grasshopper.Instances.CursorServer.AttachCursor(sender, “CursorName”);
Look at the folder:
C:\Program Files\Rhino 6\Plug-ins\Grasshopper\Cursors.

For win cursors:
System.Windows.Forms.Cursors.


#3

Thanks Dani, very helpful!
But, the first parameter is Windows.Forms.Control.
Either sender or Owner is not a Windows.Forms.Control.
How can I get a Windows.Forms.Control object associated with the component capsule?
Thank you.


#4

GH_Canvas is a Windows.Forms.Control, the components do not.