如何在vb.net的datagridview中执行所有保存,更新,编辑操作 [英] How to do all Save,Update,Edit operation in datagridview in vb.net
本文介绍了如何在vb.net的datagridview中执行所有保存,更新,编辑操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1.)我已经尝试过
这里的方程式是数据库
EquationDataset是数据集
BasicInfoTableAdapter是数据适配器
BasicInfo是表格
1.)I have tried
Here Equation is database
EquationDataset is dataset
BasicInfoTableAdapter is dataadapter
BasicInfo is table
Private Sub BindingSource1_ListChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles BindingSource1.ListChanged
'Checking for updation
If EquationDataSet.HasChanges Then
UpdatePending = True
End If
End Sub
Private Sub BasicDetailGrid_RowValidated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles BasicDetailGrid.RowValidated
If UpdatePending = True Then
BasicInfoTableAdapter.Update(EquationDataSet.BasicInfo)
UpdatePending = False
End If
End Sub
``我已经读到ListChanged在Rowvalidation之前被解雇了一段时间.
2.)我也尝试过
''I have read that ListChanged is fired before Rowvalidation for a while.
2.)I have also tried
Private Sub BasicDetailGrid_RowLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles BasicDetailGrid.RowLeave
Try
Me.Validate()
Me.BindingSource1.EndEdit()
Me.BasicInfoTableAdapter.Update(Me.EquationDataSet.BasicInfo)
Me.EquationDataSet.AcceptChanges()
Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub
''请帮助
''Please Help
推荐答案
您好
尝试这种方法(正在使用此方法并为我工作了....)
Hi
try this method( am using this and worked for me....)
Dim manager As New EquationDataSetTableAdapters.TableAdapterManager
me.basicinfobindingsource.endedit()
me.bacicinfotableadapter.update(Me.EquationDataSet.BasicInfo)
manager.UpdateAll(EquationDataSet)
Me.BasicInfoTableAdapter.Fill(Me.EquationDataSet.BasicInfo)
希望这对您有用...
Hope this works for u...
这篇关于如何在vb.net的datagridview中执行所有保存,更新,编辑操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文