Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 671495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:22:48+00:00 2026-05-14T00:22:48+00:00

I have a BindingSource that I’m using in winforms data binding and I’d like

  • 0

I have a BindingSource that I’m using in winforms data binding and I’d like to have some sort of prompt for when the user attempts to close the form after they’ve made changes to the data. A sort of “Are you sure you want to exit without saving changes?”

I’m aware that I can do this via the BindingSource‘s CurrencyManager.ItemChanged event by just flipping a “has changed” boolean.

However, I want a more robust functionality. I’d like to know when the current data is different from the original data. The event just tells me if somethings changed. A user could still change a property, hit undo, and I would still think that there is a change in the data to save.

I want to mimic this similar functionality of notepad

  • open notepad
  • type something
  • delete everything (essentially undoing what you did)
  • close notepad, notepad closes, no prompt to save changes because it knows the end state == the initial state

If this is not possible, then should I go with the ItemChanged event handler as outlined above or is there a better way?

For the record, I’m looking for something along the lines of

bool HasChanged()
{
    return this.currentState != this.initialState;
}

not this

bool HasChanged()
{
    // this._hasChanged is set to true via event handlers
    return this._hasChanged;
}

I’d just rather not have to manage the current state and the initial state myself, I’m looking for a way to grab that info from the BindingSource If I can get this functionality from the BindingSource its way more ideal since I will be able to use the functionality on many different data sources, regardless of type, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:22:48+00:00Added an answer on May 14, 2026 at 12:22 am

    You’ll have to implement the INotifyPropertyChanged interface from within your object classes, then catch whenever a change occurs through proper event handlers for your type class within your DataSource BindingSource property.

    The one object offering what you require is the DataSet, containing both the Original and Current (changed) state of an persistent entity. Then, when one cancels, all you need to call is the Rollback() method. When one accepts the changes, then a call to the AcceptChanges() method will do.

    Besides the DataSet, perhaps considering an ORM like NHibernate will do the job for you, plus allowing you to use custom defined objects, instead of a DataSet. Keeping the ISession API alive while in your form will allow the ISession to keep track of your changes whatever it may be to whatever object it is, as long as it is know by NHibernate.

    Another solution implementing the INotifyPropertyChanged interface, is at the property setter, you could stock the Original value within a private field or for every property of an object. You could simple have an abstract class with the HasChanges property return whether each property is as its Original state, then return true or false accordingly.

    I have a question regarding our interesting initial discussion. I just want to make sure of one thing. Let’s call it language barrier if we like. But publishing the PropertyChanged event through the INotifyPropertyChanged interface will also somehow “rollback” an object to its original state. The only detail you had to take care is that if the user says he doesn’t want to keep the changes, then reload this CurrentItem from the underlying database via the BackgroundWorker class and its done! No lagging from your GUI, your user has canceled the changes, and you resetted the object to its default/original state!

    Well, I guess here’s enough details to make yourself an idea, plus all of the other good answers provided by the others. I am confident you will find your way to accomplish what you want.

    Best of success! =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to database programming in WinForms, and have been using BindingSource, DataSet,
Hey guys, I have an application that I want to display some data from
I have a DataGridView that displays data from a MS Access database. I'm using
I have a Form in my application that displays some data. When I first
I have some difficulties with understanding BindingSource's behaviour. Let's look at following example: Creating
I have bind 2 separate tables using BindingSource. Left grid contains student table and
I would like to get the Type of item that a BindingSource is hooked
I'm using the ErrorProvider in VB.Net (2005) which is associated with a BindingSource that
I have a DataGridView and a BindingSource bs populated using bs.DataSource = list; where
I have several controls in a winform application that I added databindings to using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.