Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / July 2004

Tip: Looking for answers? Try searching our database.

Howto discard changes and revert?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gavin Jacobs - 05 Jul 2004 22:43 GMT
I have a form bound to a specific row in a table in a dataset. I am trying
to implement Save and Discard buttons. I have the Save button working using
the DataRowView.EndEdit method. For the Discard button I call
DataRowView.CancelEdit. The changes really are canceled, but the user input
is still there. I can't figure out how to get the Textbox to revert to the
previous value. What's the trick?

Here's the code:
   Private Sub btnPlatformSave_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnPlatformSave.Click
       Dim Row As DataRowView
       Row = CType(Me.BindingContext(DsData1, "Platform").Current,
DataRowView)
       Row.EndEdit()
       btnPlatformSave.Enabled = False
       btnPlatformDiscard.Enabled = False
   End Sub

   Private Sub btnPlatformDiscard_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPlatformDiscard.Click
       Dim Row As DataRowView
       Row = CType(Me.BindingContext(DsData1, "Platform").Current,
DataRowView)
       Row.CancelEdit()
           ' Get old values back
       btnPlatformSave.Enabled = False
       btnPlatformDiscard.Enabled = False
   End Sub
William Ryan  eMVP - 06 Jul 2004 03:35 GMT
Call the .RejectChanges method of the underlying dataset if you want to undo
everything.

Signature

W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups

> I have a form bound to a specific row in a table in a dataset. I am trying
> to implement Save and Discard buttons. I have the Save button working using
[quoted text clipped - 24 lines]
>         btnPlatformDiscard.Enabled = False
>     End Sub
Gavin Jacobs - 06 Jul 2004 12:18 GMT
William,
Unfortunately, that doesn't do it. When I call .RejectChanges, the textbox
still displays the changed value until I navigate away from the record and
then return, and then it shows the previous value (which is what I wanted,
but without the hassle of navigating away and back). In other words, I want
a way to reload the textbox with the values from the unchanged dataset.

> Call the .RejectChanges method of the underlying dataset if you want to undo
> everything.
[quoted text clipped - 30 lines]
> >         btnPlatformDiscard.Enabled = False
> >     End Sub
Gavin Jacobs - 06 Jul 2004 23:24 GMT
Here's the ticket:
Me.BindingContext(DsData1, "Platform").CancelCurrentEdit()

> I have a form bound to a specific row in a table in a dataset. I am trying
> to implement Save and Discard buttons. I have the Save button working using
[quoted text clipped - 24 lines]
>         btnPlatformDiscard.Enabled = False
>     End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.