禁止 dataGridView 控件创建没有定义的列

没有禁止之前, 控件把我没有在控件上定义的属性全都显示出来了

 我们不想要控件将我们没有定义的属性显示出来,

//定义sql
string sql = "select * from Students sd inner join StudentClass sc on sd.ClassId = sc.ClassId";
List<Students> students = scoreListServer.GetListStudent(sql); //从数据库获取数据
this.dataGridView1.AutoGenerateColumns = false; //在给控件赋值之前添加
this.dataGridView1.DataSource = students;

 

posted @ 2024-06-12 19:53  龙卷风吹毁停车场  阅读(11)  评论(0)    收藏  举报