Home All Groups Group Topic Archive Search About

Screen coordinates of selected datagridview cells left and top borders

Author
11 Jun 2006 7:11 AM
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

Author
11 Jun 2006 8:21 AM
Ahmed
do u mean this:

me.DataGridView1.SelectedCells(0).ContentBounds.Location


steve wrote:
Show quoteHide quote
> 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
Author
12 Jun 2006 6:57 AM
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.