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. Image for the cookie policy date

How to chang the mouse cursor when CellMouseHoverEnter occur

Using the GirdDataBoundGrid control, I want to chnag to mouse cursor to hand when the mouse point to a cell. My codes: private void rateBoundGrid_CellMouseHoverEnter(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e) { if (e.ColIndex == colIndexDep) { canChangCellStyle = true; this.rateBoundGrid.RefreshRange(GridRangeInfo.Cell(e.RowIndex, e.ColIndex)); } } private void rateBoundGrid_CellMouseHoverLeave(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e) { if (e.ColIndex == colIndexDep) { canChangCellStyle = false; this.rateBoundGrid.RefreshRange(GridRangeInfo.Cell(e.RowIndex, e.ColIndex)); } } private void rateBoundGrid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { if (e.RowIndex > 0 && e.ColIndex > 0) { int row, col; Point mousePoint = this.rateBoundGrid.PointToClient(Control.MousePosition); this.rateBoundGrid.PointToRowCol(mousePoint, out row, out col, -1); if (row == e.RowIndex && col == e.ColIndex && canChangCellStyle) { canChangCellStyle = false; e.Style.TextColor = Color.Blue; e.Style.Font.Underline = true; this.rateBoundGrid.Cursor = Cursors.Hand; // It does not work this.Cursor = Cursors.Hand; // It does not work } } } I add the following code to my program. It does not work... private void rateBoundGrid_CellCursor(object sender, Syncfusion.Windows.Forms.Grid.GridCellCursorEventArgs e) { e.Cursor = Cursors.Hand; } Regards, Malin

2 Replies

AD Administrator Syncfusion Team April 8, 2004 09:51 AM UTC

If you want to control the cursor, here are two techniques you can use. The simplest way is to derive the grid, and override OnSetCursor. Here is a sample. You can add additional checks to narrow where you set the cursor. Another way is to implement IMouseController and fit directly into the grid''s mouse controller architecture. You can create a class that implements the IMouseController interface which will also allow you to control the cursor. This takes a little more code but does not require that you derive the grid to use it. Here is a sample that changes the cursor over the top half of each cell. This means that anywhere else, the grid allows the other controllers a chance to handle the mouse actions. Your mouse controller must implement the IMouseController interface. The main method you have to handle is the HitTest method. Returning a non-zero hit value at that point indicates to the grid that your mousecontroller wants control of things at this point. It will then the use your controller for all messages as long as the hittest returns nonzero. This means your controller will provide the cursor, it will handle the mousedown etc. In the sample, the only functionality implemented is to change the cursor and to handle a left click.

AD Administrator Syncfusion Team April 8, 2004 11:20 PM UTC

Thank you very much!

Live Chat Icon For mobile
Up arrow icon