|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
X & Y within DataGridViewIs there a way to discover the starting X & Y position (in Pixels) of a
Cell within a DataGridView control on a Windows Form? (VS2005) I've searched everywhere, and tried everything I can think of, but can't seem to find the answer. Thanks for any help. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't. Hi ShaneO
You can use GetCellDisplayRectangle method of DataGridView, for example it dispaly position of current cell: DataGridViewCell cell = dataGridView1.CurrentCell; Rectangle r= dataGridView1.GetCellDisplayRectangle( dataGridView1.CurrentCell.ColumnIndex , dataGridView1.CurrentCell.RowIndex , false); MessageBox.Show(r.ToString()); if you want cell position within form , you must add datagridview 's top & left to rectangle I hope it helps you Best Regards, A.Hadi Aboulfazl Hadi wrote:
Show quoteHide quote > Hi ShaneO Thank-you Aboulfazl, your information was able to point me in the right > You can use GetCellDisplayRectangle method of DataGridView, for example > it dispaly position of current cell: > > DataGridViewCell cell = dataGridView1.CurrentCell; > Rectangle r= dataGridView1.GetCellDisplayRectangle( > dataGridView1.CurrentCell.ColumnIndex > , dataGridView1.CurrentCell.RowIndex , false); > > > MessageBox.Show(r.ToString()); > > if you want cell position within form , you must add datagridview 's > top & left to rectangle > > I hope it helps you > Best Regards, > A.Hadi > direction. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't. Hi!
I've used the method GetCellDisplayRectangle. But it returns correct rectangle only if the given cell is visible to the user. Otherwise (if the cell is out of visible area, if the grid is scrolled), it returns empty rectangle. Does anybody know how to get cell bounds for any cell? Thanks, Mike. *** Sent via Developersdex http://www.developersdex.com *** |
|||||||||||||||||||||||