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.
Unfortunately, activation email could not send to your email. Please try again.

How to get absolute row,col index under mouse point

Thread ID:

Created:

Updated:

Platform:

Replies:

21362 Nov 8,2004 01:10 PM Nov 8,2004 04:23 PM Windows Forms 3
loading
Tags: GridControl
Keith Steinbeck
Asked On November 8, 2004 01:10 PM

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?

Administrator [Syncfusion]
Replied On November 8, 2004 01:29 PM

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

Keith Steinbeck
Replied On November 8, 2004 03:17 PM

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 >

Administrator [Syncfusion]
Replied On November 8, 2004 04:23 PM

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.

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.

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.

;