Screen coordinates of selected datagridview cells left and top borders

S

steve

Hi All

How do I get the screen coordinates of the selected cell boundaries in a
datagridview

I need to position a form at the top left position of the selected cell
regardless of where the user clicks in the cell


Regards
Steve
 
J

Jeffrey Tan[MSFT]

Hi Steve ,

Thanks for your post!

I think Ahmed has pointed out the correct direction.
me.DataGridView1.SelectedCells(0).ContentBounds will provide the bounding
rectangle that encloses the cell's content area. If you want to get the
rectangle that represents the display area for a cell, you may give
DataGridView.GetCellDisplayRectangle a try. Pass in the selected cell's row
and column index.

To get the screen coordinate, you may use DataGridView.PointToScreen method
to convert the location point.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top