0
我有一个DataGrid有6列: 组合框,组合框,复选框;复选框;复选框,文本框C#DataGrid中填充有组合框,复选框和TextBox
我试图填充此数据网格与价值观我在网格线的列举M保存对象
public class GridLine
{
public string sColumnA { get; set; }
public bool bError { get; set; }
public string sColumnB { get; set; }
public bool bNullableB { get; set; }
public bool bCollateB { get; set; }
public bool bStaticB { get; set; }
public string sStaticB { get; set; }
(...)
}
我已经写了被设置DataGrid中最后一行PARAMS并添加新的生产线的功能,但它不能正常工作 - 我得到仅在最后一行正确设置组合框,其他:
private void AddLine(GridLine gl)
{
DataGridViewComboBoxCell cellMs = (DataGridViewComboBoxCell)this.Rows[this.Rows.Count - 1].Cells[0];
DataGridViewComboBoxCell cellOra = (DataGridViewComboBoxCell)this.Rows[this.Rows.Count - 1].Cells[1];
DataGridViewCheckBoxCell cellNull = (DataGridViewCheckBoxCell)this.Rows[this.Rows.Count - 1].Cells[2];
DataGridViewCheckBoxCell cellColl = (DataGridViewCheckBoxCell)this.Rows[this.Rows.Count - 1].Cells[3];
DataGridViewCheckBoxCell cellStat = (DataGridViewCheckBoxCell)this.Rows[this.Rows.Count - 1].Cells[4];
DataGridViewTextBoxCell cellStatText = (DataGridViewTextBoxCell)this.Rows[this.Rows.Count - 1].Cells[5];
cellMs.Value = gl.sColumnA;
cellOra.Value = gl.sColumnB;
cellNull.Selected = gl.bNullableB;
cellColl.Selected = gl.bCollateB;
cellStat.Selected = gl.bStaticB;
cellStatText.Value = gl.sStaticB;
this.Rows.Add();
}
我不知道我在做什么错。
非常感谢