作为 C# 的新手,我遇到了格式化数据网格列的问题。 所以,我像这样填充我的网格:
SQLiteDataAdapter adapter = new SQLiteDataAdapter("select * from table", myDBCon);
DataSet ds = new DataSet();
adapter.Fill(ds);
myDBCon.Close();
dataGridView4.DataSource = ds.Tables[0];
而且我希望能够自己决定显示列的顺序是什么以及不显示哪些列。 我尝试使用它的上下文菜单手动将列添加到控件,但我最终得到了一个包含我声明的列的网格,然后是所有列,再次显示...... 我只希望显示我声明的列,而不是全部,并且只显示一次,而不是两次。 我一定是在某处遗漏了一个简单的设置,否则在设计时添加列将毫无意义
我做错了什么?
请您参考如下方法:
I tried adding columns manually to the control using it's context menu, but I ended up having a grid with my declared columns, followed by ALL the columns, shown again
设置 DataGridView.AutoGenerateColumns = false
然后将仅使用预定义的列
我不确定,但恐怕无法通过设计器设置此设置。在InitializeComponents()
