Solved

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

Posted on 2007-04-05
3
222 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now