How can I clear rows in DataGridView with C#?

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

    Simply add this line at beginning of your event:

    dgv_nameOfGridView.DataSource=false;
    

    Now every time you click it will erase the dgv..

提交回复
热议问题