How can I clear rows in DataGridView with C#?

后端 未结 13 2251
野的像风
野的像风 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:43

    Is your DataGridView bound to a DataSource, i think thats why its not allowing you to clear it since its bound to an underlying DataTable or List.

    you could try setting the DataSource Property to null

    datagridview1.DataSource = null; for clearing

提交回复
热议问题