How can I clear rows in DataGridView with C#?

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

    First clear DataSource and then clear DataGridView

    in VB

     datagridview1.DataSource = Nothing
     datagridview1.Rows.Clear()
    

    hope help

提交回复
热议问题