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 do I convert a point to a grid row and column?

I'm sure I've seen code to do this before, but I can't seem to find it. How does one convert an X,Y coordinate into a row and column when the user clicks on the grid (say, for example, in the gri'd MouseUp event)?

1 Reply

AD Administrator Syncfusion Team October 15, 2003 02:31 PM UTC

You use the grid.PointToRowCol method. The point you pass in must be in the grid coordinates. Point pt = grid.PointToClient(Control.MousePosition); int rowIndex, colIndex; grid.PointToRowCol(pt, out rowIndex, out colIndex); If you are in one of the grid's mouse events, the e.X and e.Y are in the grid's coordiante system, so you can just use Point pt = new Point(e.X, e.Y); to get the point and not have to call PointToClient.

Live Chat Icon For mobile
Up arrow icon