Link to home
Start Free TrialLog in
Avatar of TimBPowell
TimBPowell

asked on

DataGridView Problem getting Column and Row Number

I have always used the Standard .net Datagrid but need to use the Datagridview on this occassion.  My problem is simple but I have spent several hours on it so not that simple to me.  In a datagrid to find the current column I always used datagrid.currentcell.columnnumber or datagrid.currentcell.rownumber.
These don't exist for datagridview so I thought i'd try datagridview.currentcell.columnindex but I always get 0.

I have my grid setup with around 20 rows and 60 columns but just cannot find the column or row number.

I know it must be simple but I need your help.

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Y = rowindex
X = columnindex

All zero based
DataGridView1.CurrentCell.ColumnIndex works fine for me. You might also like to try DataGridView1.CurrentCellAddress.X
>> DataGridView1.CurrentCell.ColumnIndex works fine for me

For me too webtubbs
Avatar of TimBPowell
TimBPowell

ASKER

Thanks for your help.  Thought it was easy.  Just had brain lock this morning!