Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

column order problem in dataGridViews in C#

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;

like image 788
chook Avatar asked Dec 29 '22 22:12

chook


1 Answers

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

like image 160
Henk Holterman Avatar answered Jan 09 '23 19:01

Henk Holterman