|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How To Cancel Edits on a control?Using Visual Basic 2005 how do I cancel edits on a databound control. I
want the user to be able to cancel all edits on a form. My main databound control is a DataGridView which is bound to a BindingSource, which in turn is bound to a SQL Server data source. I tried ResetBindings, but nothing appears to happen visually, and the bindingsource's HasChanges method indicates that changes have been made even after I attempt to use it. Thanks, Crazy Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuExit.Click Dim changes As DataSet = DsProduct1.GetChanges() Dim answer As DialogResult If Not changes Is Nothing Then answer = MessageBox.Show("Save data changes?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) If answer = DialogResult.Yes Then Dim count As Integer = dbProduct.Update(changes) MessageBox.Show("Database updated " & count & " rows successfully") DsProduct1.AcceptChanges() End If End If Me.Close() End Sub Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuExit.Click Dim changes As DataSet = DsProduct1.GetChanges() Dim answer As DialogResult If Not changes Is Nothing Then answer = MessageBox.Show("Save data changes?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) If answer = DialogResult.Yes Then Dim count As Integer = dbProduct.Update(changes) MessageBox.Show("Database updated " & count & " rows successfully") DsProduct1.AcceptChanges() End If End If Me.Close() End Sub dpie***@gmail.com wrote:
Show quoteHide quote > Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As Thanks,> System.EventArgs) Handles mnuExit.Click > Dim changes As DataSet = DsProduct1.GetChanges() > Dim answer As DialogResult > If Not changes Is Nothing Then > answer = MessageBox.Show("Save data changes?", "Save", > MessageBoxButtons.YesNo, MessageBoxIcon.Warning) > If answer = DialogResult.Yes Then > Dim count As Integer = dbProduct.Update(changes) > MessageBox.Show("Database updated " & count & " rows > successfully") > DsProduct1.AcceptChanges() > End If > End If > Me.Close() > End Sub I actually ended up using RejectChanges which seems to work fine in conjunction with HasChanges. Thanks again,
Should I Use "Dim ___ As New ___"?
Icons in Application Menus VB.Net File.Copy Conundrum Playing System Sounds/WAV files Tracking changes made to form... MDI Parent/Child forms KeyDown event Printing Question Datetime arithmetic in VB.Net? XmlHttp can access webservices from javascript, but not from within applications? |
|||||||||||||||||||||||