C#Winform中后台DataGridView绑定列会多一行???
代码://bindcolumndisplayCheckBox(dataGridView1,"ckbox","选择");DisplayCol(dataGridView1,"...
代码:
// bind column
displayCheckBox(dataGridView1, "ckbox", "选择");
DisplayCol(dataGridView1, "XMBH", "项目编号");
DisplayCol(dataGridView1, "XMMC", "项目名称");
this.dataGridView1.DataSource = ds.Tables["one"].DefaultView;
ds = null;
//绑定CheckBox
private void displayCheckBox(DataGridView dgv, string name, String headerText)
{
dgv.AutoGenerateColumns = false;
DataGridViewCheckBoxColumn obj = new DataGridViewCheckBoxColumn();
obj.HeaderText = headerText;
obj.Name = name;
obj.Resizable = System.Windows.Forms.DataGridViewTriState.True; obj.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.dataGridView1.Columns.Add(obj); } 展开
// bind column
displayCheckBox(dataGridView1, "ckbox", "选择");
DisplayCol(dataGridView1, "XMBH", "项目编号");
DisplayCol(dataGridView1, "XMMC", "项目名称");
this.dataGridView1.DataSource = ds.Tables["one"].DefaultView;
ds = null;
//绑定CheckBox
private void displayCheckBox(DataGridView dgv, string name, String headerText)
{
dgv.AutoGenerateColumns = false;
DataGridViewCheckBoxColumn obj = new DataGridViewCheckBoxColumn();
obj.HeaderText = headerText;
obj.Name = name;
obj.Resizable = System.Windows.Forms.DataGridViewTriState.True; obj.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.dataGridView1.Columns.Add(obj); } 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询