Hello,

In my winform there's a datagrid1 based on tblCD_Detail. I want to select a row and then delete the selected row by hitting the Delete-key and then update the underlying datasource. I wrote the following code:

VB Code:
  1. Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
  2.  
  3.         If keyData = Keys.Delete Then
  4.             If DataGrid1.IsSelected(Me.DataGrid1.CurrentCell.RowNumber) Then
  5.                 Me.DSlistboxes.Tables("tblCD_detail").Rows.RemoveAt(DataGrid1.CurrentCell.RowNumber)
  6.                 Return True
  7.                 End If
  8.         End If
  9.  
  10.         Return MyBase.ProcessCmdKey(msg, keyData)
  11.  
  12.         DataConnection.Open()
  13.         Me.OleDbDataAdaptertblCD_detail.Update(DSlistboxes, "tblCD_detail")
  14.         DataConnection.Close()
  15.  
  16.     End Function

To update the datasource I use oledbdataadaptertblCD_detail which is generated by the wizard to avoid problems. The problem is that I can delete a row in the datagrid but the datasource isn't updated, however when I delete a single field in the dataset and then update the datasource with the same code:

Me.OleDbDataAdaptertblCD_detail.Update(DSlistboxes, "tblCD_detail")

then the datasource is updated.

I really don't know whats going wrong.

Any idea??

Tom