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

mouse events - hover

Thread ID:

Created:

Updated:

Platform:

Replies:

981 Sep 10,2002 10:44 AM UTC Nov 19,2003 06:00 PM UTC WinForms 4
loading
Tags: GridControl
Andre King
Asked On September 10, 2002 10:44 AM UTC

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

Clay Burch [Syncfusion]
Replied On 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()); }

Andre King
Replied On September 12, 2002 08:41 PM UTC

Just what I needed, thanks.

Administrator [Syncfusion]
Replied On 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()); > } >

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

CONFIRMATION

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.

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

;