How do I get the X coordinate of a DGV column relative to the forms left edge? Thanks...
Printable View
How do I get the X coordinate of a DGV column relative to the forms left edge? Thanks...
You could iterate the columns until you get to the column in question and add the values of their Width properties.
I am not sure if there is a better way of doing this.
I thought there was a way to get the X location without having to iterate, but I can't find it now. Anyone know?
Are you in the cell?
vb.net Code:
MessageBox.Show(Me.DataGridView1.CurrentCellAddress.X.ToString())
Or do you know its name?
vb.net Code:
MessageBox.Show(Me.DataGridView1.Columns("ContactName").Index.ToString())
I'm not looking for the index of the column, but rather its screen coordinate in pixels or whatever the units are.
Grid.GetCellDisplayRectangle(columnIndex, rowIndex, false)
Hi bogeco,
this thread is 10 Years old ??
why are you doing this
this thread is number 1 in google search for this topic, it be useful for people