Delete row in datagrid

  • Thread starter Thread starter William Ryan
  • Start date Start date
W

William Ryan

What are you having trouble with? Are you trying to make
a control, use it as a class etc?
 
Hi, I want the function PreProcessMessage to fire (code below) when I select
a record and type the delete key.
I have a DataGrid called grdTown that is populated with data from a
DataTable called mdtTown [also a DataAdapter (madpTown) and
BindingBaseManager (mbmbTown)].

Cheers, Graeme.

Public Class SubClass_DataGrid

Inherits 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
 
Back
Top