0

如何在 Devexpress gridview 中添加新行,当我们从 List objlst 设置 DataSource 时,我想在运行时添加新行。

private void SetData()
{
    List<CITEM> lstItem = new List<CITEM>();

    gridControl1.DataSource = lstItem;

    gridView1.PopulateColumns();
}

private void button1_Click(object sender, EventArgs e)
{
    gridView1.AddNewRow();
}
4

2 回答 2

0

如果您将列表更改为绑定列表,它将起作用

于 2012-07-10T06:09:55.567 回答
0
private void button1_Click(object sender, EventArgs e)
{
    object[] obj = //your row object;
    gridView1.AddNewRow();
    gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[0], obj[0].ToString());  
    gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1], obj[1].ToString());  
    gridView1.UpdateCurrentRow(); 
}
于 2019-09-30T07:18:33.097 回答