DataGridView Cell Position

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

How do I get DataGridViewCell cell position in a window?

For a button I would do this:
this.Button.PointToClient(this.Button.Location)

But what do I do for DataGridViewCell?


Thanks


Peter
 
Hi Peter,

Because the DataGridViewCell is inside the DataGridView, we cannot get the
location of the cell by any properties.

An alternative is to caculate the total size of the left and upper cells.
Then add the value of the DataGridView.Location to get the relative
position of the cell.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Kevin Yu said:
Hi Peter,

Because the DataGridViewCell is inside the DataGridView, we cannot get the
location of the cell by any properties.

An alternative is to caculate the total size of the left and upper cells.
Then add the value of the DataGridView.Location to get the relative
position of the cell.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

I do not understand what you mean by "total size of the left and upper
cells", do you have an example?
 
Hi Peter,

For example, the cell is on the 2nd row and 3rd column. In this case, we
need to collection the width of column 1 and 2, and the height of row 1. So
the left edge of cell(2,3) is width(1)+width(2) and the top is at height(1).

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Kevin Yu said:
Hi Peter,

For example, the cell is on the 2nd row and 3rd column. In this case, we
need to collection the width of column 1 and 2, and the height of row 1.
So
the left edge of cell(2,3) is width(1)+width(2) and the top is at
height(1).

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Thank You
 
You're welcome.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top