Solved

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

Posted on 2007-04-05
3
230 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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