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.
Unfortunately, activation email could not send to your email. Please try again.

Delete multiple rows from DatGridView (VS2005)

Thread ID:

Created:

Updated:

Platform:

Replies:

41127 Feb 22,2006 04:04 PM Sep 1,2006 04:55 AM Windows Forms 3
loading
Tags: FAQ
LarryBye
Asked On February 22, 2006 04:04 PM

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.

stanleyj [Syncfusion]
Replied On February 23, 2006 01:29 AM

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

LarryBye
Replied On February 23, 2006 11:55 AM

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

Administrator [Syncfusion]
Replied On September 1, 2006 04:55 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;