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

How to chang the mouse cursor when CellMouseHoverEnter occur

Thread ID:





12694 Apr 8,2004 01:47 AM UTC Apr 8,2004 11:20 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On April 8, 2004 01:47 AM UTC

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

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On April 8, 2004 11:20 PM UTC

Thank you very much!


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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