We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Delete multiple rows from DatGridView (VS2005)

VS2005 does not have a DataGrid, it uses the new DataGridView. I''m looking for code that will allow me to delete multiple rows from the DataGridView and which method/event I should place the code. I would like the users to do this by pressing the DEL key. Any ideas/suggestion appreciated.

3 Replies

ST stanleyj Syncfusion Team February 23, 2006 06:29 AM UTC

Hi LarryBye, If you have the row header, clicking it selects the rows then the Del key removes the rows. Is that not sufficient? Regards, Stanley


LA LarryBye February 23, 2006 04:55 PM UTC

Here is how I ending up handling it. I trapped the key down forr the "delete" key Private Sub dgBadData_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dgBadData.KeyDown If e.KeyCode = Keys.Delete Then If MessageBox.Show("Are you sure you want to delete the selected record(s)?", _ "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.No Then e.Handled = True End If End If End Sub Then if the user says "yes" then I used the UserDeleteRow: Private Sub dgBadData_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles dgBadData.UserDeletedRow Me.TblACBadDataTableAdapter.Update(AirClicDataSet) Me.lblRowCount.Text = "Total Records: " & dgBadData.RowCount End Sub


AD Administrator Syncfusion Team September 1, 2006 08:55 AM UTC

u can keep a list of deleted items. When u catch a delete event u should add the current row information to that list and then delete that object from the database

>VS2005 does not have a DataGrid, it uses the new DataGridView. I''m looking for code that will allow me to delete multiple rows from the DataGridView and which method/event I should place the code. I would like the users to do this by pressing the DEL key. Any ideas/suggestion appreciated.

Loader.
Live Chat Icon For mobile
Up arrow icon