Detect a property change on any control
is there way detect when property changes? i have been fiddling around property grid control , it's quite handy. it throws events when change particular properties it. but nice if there way detect time property changes given control.
anyone know of way that?
you have create event handler rised when propery changed.
check code:
using system.componentmodel; namespace sdksample { // class implements inotifypropertychanged // support one-way , two-way bindings // (such ui element updates when source // has been changed dynamically) public class person : inotifypropertychanged { private string name; // declare event public event propertychangedeventhandler propertychanged; public person() { } public person(string value) { this.name = value; } public string personname { get { return name; } set { name = value; // call onpropertychanged whenever property updated onpropertychanged("personname"); } } // create onpropertychanged method raise event protected void onpropertychanged(string name) { propertychangedeventhandler handler = propertychanged; if (handler != null) { handler(this, new propertychangedeventargs(name)); } } } }
more info here.
mitja
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment