c# - Has the DataSource been changed via a BindingSource? -


i'm using bindingsource connect single large data-structure numerous controls (no sql, 1 data-structure, lots of controls). old-style windows forms application, visual studio 2012 express. have managed wrap numerous gui components properties work around lack of direct support control binding of things radio button groups, multi-select listboxes, title bar, etc. works great, updates flow nicely in both directions between gui , data-structure.

i need track if any changes data-structure have been made via control on gui, can't see how (i did @ previous related questions here)... needed provide simple indication of "changes made not saved", asterisk in title bar , warning if user tries exit application without saving changes.

thanks in advance !

you'll have implement inotifypropertychanged interface within object classes, catch whenever change occurs through proper event handlers type class within datasource bindingsource property.

here's example:

using system; using system.componentmodel;  namespace consoleapplication1 {     internal class program     {         class notifications         {             static void main(string[] args)             {                 var davenadler = new person {name = "dave"};                 davenadler.propertychanged += personchanged;             }              static void personchanged(object sender, propertychangedeventargs e)             {                 console.writeline("something changed!");                 console.writeline(e.propertyname);             }         }     }      public class person : inotifypropertychanged     {         private string _name = string.empty;         private string _lastname = string.empty;         private string _address = string.empty;          public string name         {             { return this._name; }             set             {                 this._name = value;                 notifypropertychanged("name");             }         }          public string lastname         {             { return this._lastname; }             set             {                 this._lastname = value;                 notifypropertychanged("lastname");             }         }          public string address         {             { return this._address; }             set             {                 this._address = value;                 notifypropertychanged("address");             }         }           public event propertychangedeventhandler propertychanged;         private void notifypropertychanged(string info)         {             if (propertychanged != null)             {                 propertychanged(this, new propertychangedeventargs(info));             }         }     } } 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -