Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find column name with column index in DataGridView?

I want to find column name in DataGridView. I have column index. How can I find it.

dGVTransGrid.CurrentCell.ColumnIndex: I want it's column name.

Plz help.

Thanks.

like image 371
Nagendra Kumar Avatar asked Sep 29 '10 06:09

Nagendra Kumar


1 Answers

There may be a better way, but why don't you just ask the DataGridView what the column with that index is called?

int columnIndex = dGVTransGrid.CurrentCell.ColumnIndex; string columnName = dGVTransGrid.Columns[columnIndex].Name; 
like image 126
Jon Skeet Avatar answered Sep 22 '22 16:09

Jon Skeet