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

mouse events - hover

Hi, I would like to catch the mouse hover event and determine the cell the mouse is on. The intent is to display a user control over the cell. Can you suggest the best method for this? The mouse hover event only gives a system event (no x,y). I started looking at the MouseDispatchController but am getting lost. thanks, a

4 Replies

CB Clay Burch Syncfusion Team September 10, 2002 11:54 AM UTC

Here is code that will retrieve the row and col numbers of the hover cell as well as the cell rectangle. private void gridControl1_MouseHover(object sender, System.EventArgs e) { Point pt = this.gridControl1.PointToClient(Cursor.Position); int row, col; this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true); Rectangle cellRect = this.gridControl1.RangeInfoToRectangle(GridRangeInfo.Cell(row, col)); Console.WriteLine(cellRect.ToString()); }


AK Andre King September 12, 2002 08:41 PM UTC

Just what I needed, thanks.


AD Administrator Syncfusion Team November 19, 2003 04:45 PM UTC

I have found that this does not work correctly if the grid has horizontal scrolling and you have scrolled the grid. In this case the first visible column returns 1, when it is actually column 6 or 7 or whatever. Do you know of a way that I can get the true column that the mouse is over? Thanks for your help. > Here is code that will retrieve the row and col numbers of the hover cell as well as the cell rectangle. > > > private void gridControl1_MouseHover(object sender, System.EventArgs e) > { > Point pt = this.gridControl1.PointToClient(Cursor.Position); > > int row, col; > this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true); > > Rectangle cellRect = this.gridControl1.RangeInfoToRectangle(GridRangeInfo.Cell(row, col)); > > Console.WriteLine(cellRect.ToString()); > } >


AD Administrator Syncfusion Team November 19, 2003 06:00 PM UTC

Use this grid method instead of the one on the ViewLayout. this.gridControl1.PointToRowCol(pt, out row, out col, -1);

Loader.
Live Chat Icon For mobile
Up arrow icon