Getting the Screen Coordinates of a Cell in a DataGridView

16. September 2009 05:23 by Mrojas in General  //  Tags:   //   Comments (0)

Well, this is actually quite easy.

To get the X and Y of a Cell you just need to do something like:

grid.CurrentCell.ContentBounds.Location

or for the selected cell use:

grid.SelectedCells[0].ContentBounds.Location

 

And to convert that to screen coordinates do:

grid.PointToScreen(grid.CurrentCell.ContentBounds.Location)

 

mmm Well I found that

grid.GetCellDisplayRectangle(columnIndex, rowIndex, false) is a better alternative, because it will give you the Rectangle for the whole Cell