控制不自动显示数据库中未绑定的列属性是AutoGenerateColumns。
附加控制DataGridView隔行背景色的设置方法。
1 //DataGridView名字为dgvResult
2 //设置隔行背景色
3 this.dgvResult.RowsDefaultCellStyle.BackColor = Color.Bisque;
4 this.dgvResult.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
5 //设置不自动显示数据库中未绑定的列
6 this.dgvResult.AutoGenerateColumns = false;
右上角的小三角形进去点击编辑列添加列在数据就是DataPropertyName那一栏输入数据库的列名