Question delete all rows in one click on datagridview

JJ_98

New member
Joined
Feb 12, 2016
Messages
3
Programming Experience
Beginner
Hi i want to know what code should i use to command a button to delete all rows in just one click, for now i only know this code
Record will be the name of my table on database that is why..


Private Sub delete_all_Click


Me.RecordBindingSource.RemoveCurrent()


End Sub


End Class


in that way it will function to delete rows one by one ,but the problem i want to delete all data on each of my fields by clicking the button delete all .Should i need to loop it can anyone teach me how to do that cause i'm a beginner in visual basic studio 2010 Thanks!
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,602
Location
Sydney, Australia
Programming Experience
10+
I just want to clarify something before providing a solution. When you say this:
i want to delete all data on each of my fields
does that mean that you want to delete each of the records or does it mean that you want to keep all the records and clear each field within each one? I would think that it would be the former but the language you use makes it sound like the latter.
 

JJ_98

New member
Joined
Feb 12, 2016
Messages
3
Programming Experience
Beginner
oh sorry for that i mean i want to clear all data in all fields in one click i could not find delete all command, any help please thanks!
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,602
Location
Sydney, Australia
Programming Experience
10+
There is no "delete all" command. You would need to use a loop of some kind; possibly nested loops. There are a number of different implementations that would do the job, which could involve looping through the Rows of the grid or looping through the BindingSource.
 
Top Bottom