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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I change the mouse cursor in GridControl, GridDataBoundGrid and GridGroupingControl?

Description

When you move the mouse cursor over the Grid, by default the arrow cursor is displayed. You can change the mouse cursor by using the following three methods.

Solution

You can implement this in three ways,

  1. Using CellCursor event.
  2. Using OnSetCursor.
  3. Using IMouseController interface.

Using CellCursor event

The easiest way to change the cursor for the grid cells is to handle the Gridcontrol's CellCursor event and assign the cursor object to the Cursor property and set e.Cancel to true. This event method is called when the Grid queries, the cursor that is to be displayed for a cell and before the cell renderer returns its cursor. But, also other MouseControllers can take control in cases like ResizingColumns, ResizingRows, and Drag/Drop displaying mouse cursors according to the controllers.

Refer to the following code example for GridControl, GridDataBoundGrid and GridGroupingControl respectively.

GridControl

C#

VB

GridDataBoundGrid

C#

VB

GridGroupingControl

C#

VB

Using OnSetCursor()

In this method, derive the Grid and override the OnSetCursor. You can also add additional checks to narrow down as to where you want to set the cursor.

Refer to the following code example for GridControl OnSetCursor method and similarly for GridDataBoundGrid and GridGroupingControl.

C#

VB

Using IMouseController

In this method, implement the IMouseController interface that allows you to control the cursor, and fit it directly into the grid's mouse controller architecture. This requires more code but, it is not required to derive the Grid. The main method that you handle in this is the HitTest that returns a non-zero hit-test value to indicate the Grid at the point where your mouse controller wants the control.

Refer to the following code example for GridControl IMouseController method and similarly for GridDataBoundGrid and GridGroupingControl.

C#

VB

The following screenshot illustrates the output.

Figure 1: Cursor change in GridControl

C:\Users\ApoorvahR\Desktop\Note.pngNote: In the above screenshot, you can see the mouse cursor changed while hovering on GridControl and a similar output arrives for both GridDataBoundGrid and GridGroupingControl.

Sample

ChangedMouseCursor-C#.

ChangedMouseCursor-VB

Article ID: Published Date: Last Revised Date: Platform: Control:
451 04/30/2011 04/21/2015 WinForms GridControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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