Solved

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

Posted on 2007-04-05
3
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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