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 get absolute row,col index under mouse point

How can I get the absolute row,col index of a grid cell under the mouse? The Grid.CellClicked event gives the "proper" absolute coords, but if you are using Point pt = m_Grid.PointToClient(Cursor.Position); int row, col; m_Grid.ViewLayout.PointToClientRowCol(pt,out row, out col, false, GridCellSizeKind.ActualSize); you get coords of the VISIBLE grid. This works fine if the whole grid fits on the screen, but if not things don''t work quite so well; for example if you are trying to map the coords of the cell to an underlying data structure. So the question becomes: How can I get the absolute cell coords inside a non-MouseEvent-based method or handler, like ContextMenu.Popup?

3 Replies

AD Administrator Syncfusion Team November 8, 2004 06:29 PM UTC

Try using grid.PointToRowCol(pt, out row, out col, -1); // where pt is in the grid coordinate system


KS Keith Steinbeck November 8, 2004 08:17 PM UTC

Great! That seems to do what I need. I''m curious though; the docs for that function state: Points that below the last visible row or right of the last column will be adjusted as defined in the fixOutOfRange parameter. Use -1 if Empty should be returned. The return type is bool, and I don''t think there is a Boolean.Empty. Is this an error in the docs, or am I misunderstanding how this applies? >Try using > >grid.PointToRowCol(pt, out row, out col, -1); // where pt is in the grid coordinate system >


AD Administrator Syncfusion Team November 8, 2004 09:23 PM UTC

It is the row and col returned values that are influenced by the fixOutOfRange value. A zero returns a ''closest'' existing row/col. A non-zero value will return -1''s for both values.

Loader.
Live Chat Icon For mobile
Up arrow icon