Solved

VB.net - prompting user if they want to save changes

Posted on 2007-04-05
3
229 Views
Last Modified: 2010-04-23
Hi
I've an application with many inputs (split across multiple user defined controls).

When the user tries to exit, I'd like to prompt them if they want to save changes (this part is ok, its knowing if they've made changes before prompting is the part I need to know how to do)

Is there an easy way to know if user has made changes - rather than record every controls original value , and then check through every control if the value has been changed when the user wants to exit?

Thanks in advance
0
Comment
Question by:rwallacej
3 Comments
 
LVL 7

Accepted Solution

by:
dctuck earned 400 total points
ID: 18856674
When I do this, I have a private Boolean variable called something like IsChanged, which I then set each time a value of a control changes.

For things like textboxes and comboboxes and the likes, I create a method called something like ValueChanged which handles the TextBox.TextChanged and ComboBox.SelectedIndexChange events for each control I need to check. That way, you don't have to check each individual one - the one method does it for them all.
0
 

Author Comment

by:rwallacej
ID: 18856825
thanks, this seems to work - I'll get back later and award points if nothing comes up
0
 
LVL 34

Assisted Solution

by:Sancler
Sancler earned 100 total points
ID: 18857264
If the controls are bound to a dataset/datatable then you can check that to see if there are changes

    'make sure any changes from the control/s are committed to the datasource ... details depend on the binding/s
    BindingContext(myDataSource).EndCurrentEdit
    If myDataSet.HasChanges Then
        'your warning, and response, code goes here
        MsgBox("Changes made")
    End If

or, if any datatable/s are not in a dataset

    'make sure any changes from the control/s are committed to the datasource ... details depend on the binding/s
    BindingContext(myDataSource).EndCurrentEdit
    Dim dr() As DataRow = myTable.GetChanges
    If Not dr Is Nothing Then
        'your warning, and response, code goes here
        MsgBox("Changes made")
    End If

for each datatable.

Roger
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question