views:

201

answers:

2

I fill the dataGrid by binding a dataSet to the grid, with aDataGridView.dataSource = aDataSet.aTableName, when I trace the code after using this function, all of the column indexes are reset to 0, what can I do? how can I find new real indexes? can I use a different function?

I tried this code I found here, but it's not working: this.dataGridView1.DataSource = null; this.dataGridView1.Columns.Clear(); this.dataGridView1.DataSource = data;

+2  A: 

Set dataGridView1.AutoGenerateColumns = false; before assigning the DataSource.

Henk Holterman
+1  A: 

Can you provide some sample code as to what you're trying to accomplish? I just wrote a quick simple app where I set the DataSource of a DataGridView to some DataTable, and looped through all the columns of the DataGridView and the column index was accurate. Post some code, and maybe we can help...

BFree