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:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean If keyData = Keys.Delete Then If DataGrid1.IsSelected(Me.DataGrid1.CurrentCell.RowNumber) Then Me.DSlistboxes.Tables("tblCD_detail").Rows.RemoveAt(DataGrid1.CurrentCell.RowNumber) Return True End If End If Return MyBase.ProcessCmdKey(msg, keyData) DataConnection.Open() Me.OleDbDataAdaptertblCD_detail.Update(DSlistboxes, "tblCD_detail") DataConnection.Close() 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




Reply With Quote