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

datagrid traps 2nd delete key not first

First of all, thanks for the ton of information!!!! I followed your advice in the following section trying to prevent rows from being deleted in my datagrid. It works great EXCEPT for the first time the DEL key is pressed. 5.58 How can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key? The following is my code. I think it is exactly like your. Is there a way to trap the first “DEL” key???? Public Class DataGrid_Custom Inherits Windows.Forms.DataGrid Private Const WM_KEYDOWN = &H100 Public Overrides Function PreProcessMessage(ByRef msg As System.Windows.Forms.Message) As Boolean Dim keyCode As Keys = CType((msg.WParam.ToInt32 And Keys.KeyCode), Keys) If msg.Msg = WM_KEYDOWN And keyCode = Keys.Delete Then If MessageBox.Show("Delete This Row?", "Confirm Delete", MessageBoxButtons.YesNo) = DialogResult.No Then Return True End If End If Return MyBase.PreProcessMessage(msg) End Function End Class

Loader.
Live Chat Icon For mobile
Up arrow icon