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();
}
我不知道我在做什麼錯。
非常感謝