How can I clear rows in DataGridView with C#?

后端 未结 13 2223
野的像风
野的像风 2020-12-03 18:19

Following Error in this line.

datagridview1.Rows.Clear()

but this line gives error:

Cannot clear this list.

13条回答
  •  抹茶落季
    2020-12-03 18:24

    You can use this simple method:

    First clear your DataTable and then refresh your DataGridView

    dataTable.Clear();
    dataGridView.Refresh();
    

    Hope this help

提交回复
热议问题