Remove row from DataGridView

后端 未结 2 1666
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 00:36

In order to initialize my VouchersDGV Data Grid View I\'m Using the following

 DGV.AllowUserToDeleteRows = True
 For i = 1 To DGV.RowCount - 1
     DGV.Rows.Remo         


        
相关标签:
2条回答
  • 2021-01-25 01:02
    If Not DGV.Rows(i).IsNewRow Then
        DGV.Rows.RemoveAt(i)
    End If
    

    Add this condition to your loop. Alternatively, you could also use DGV.RejectChanges() which will reset all the row status to original.

    0 讨论(0)
  • 2021-01-25 01:02

    If your goal is to empty the row collection, you can just use the Clear method of the Rows collection:

    DGV.Rows.Clear()

    Hope this helps.

    0 讨论(0)
提交回复
热议问题