Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

VB 2008 - Delete all DataGridView records at once

Here is what I want to do (but don't know how to do it!)  Maybe it can't be done this way.  The grid contains Bound data.

    Private Sub cmdDeleteAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDeleteAll.Click

        EvalItemsDataGridView.SelectAll()
        'Call BindingNavigatorDeleteItem_Click()
    End Sub
0
ljcor
Asked:
ljcor
  • 2
1 Solution
 
shahprabalCommented:
delete all the records in the underlying datatable (assuming thats what your datagridview is bound to).
for each targetRow as datarow in reportdataset.tables("table1").rows
targetRow.delete
next

 
0
 
ljcorAuthor Commented:
Nice and neat - short and sweet; that's what I wanted.  Thanks greatly.
0
 
shahprabalCommented:
Glad I could help.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now