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.
You can implement this in three ways,
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.
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.
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.
The following screenshot illustrates the output.
Figure 1: Cursor change in GridControl
Note: 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.
This page will automatically be redirected to the sign-in page in 10 seconds.