How to programmatically add a row to a datagridview when it is data-bound?

后端 未结 4 620
别跟我提以往
别跟我提以往 2020-12-20 15:56

How can I add a row to a datagridview control if it is bounded to a datasource (datatable) ? Thanks!

4条回答
  •  太阳男子
    2020-12-20 16:51

    // I manipulated a binding list. Here I was moving a row down in sequence.

    BindingList lst = (BindingList)DataGridView.DataSource;
    MyType objQcc = lst[rowIndex];
    lst.Insert(rowIndex + 2, objQcc);
    lst.RemoveAt(rowIndex);        
    

提交回复
热议问题