提升 dataGridView 效率,让万笔数据绑定 datatable (dataGridView 中快速导入 datatable)

代码中输入
dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
DataGridViewTextBoxColumn idColumn = new DataGridViewTextBoxColumn();
idColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.DataSource = dt;  //dt 是查询结果后的数据源

千万不要设定
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

你可能感兴趣的:(dataGridView1,提升,DataSource,datatable,效率,绑定)