ArunVashist
asked on
Visual C#, Is there any way to know if values are changed on form or not
HI Friends,
I am working on VS 2008 with C# for a Windows Application development, I want to ask you that, is there any way to know if values are changed in any control on the form or not. I am using unbound controls in my windows form which fetch values from dataset on form load, I need to track if user make any change on the form or not, if yes then show a message box alerting user data is changed since its loaded, i have around 45-50 controls on my form i.e textbox, combobox, radio buttons and buttons.
thanks,
Arun Vashist
I am working on VS 2008 with C# for a Windows Application development, I want to ask you that, is there any way to know if values are changed in any control on the form or not. I am using unbound controls in my windows form which fetch values from dataset on form load, I need to track if user make any change on the form or not, if yes then show a message box alerting user data is changed since its loaded, i have around 45-50 controls on my form i.e textbox, combobox, radio buttons and buttons.
thanks,
Arun Vashist
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Friends,
Well the given solutions require lots of coding level efforts, actually i was asking if there is any way we could capture the value changed in textboxes, checkboxes or dropdowns using existing control properties/event.
Well suggested onChange event is there but again it require me to code individual control, so its not feasible for me. if anything else is available kindly suggest.
and Wikkard and Anarki, if possible please send me a sample code to create custom controls as suggested.
thanks,
Well the given solutions require lots of coding level efforts, actually i was asking if there is any way we could capture the value changed in textboxes, checkboxes or dropdowns using existing control properties/event.
Well suggested onChange event is there but again it require me to code individual control, so its not feasible for me. if anything else is available kindly suggest.
and Wikkard and Anarki, if possible please send me a sample code to create custom controls as suggested.
thanks,
ASKER
Thanks, I am now using a Global bool variable which is set to true whenever there is any change in control value and using this value I raise a Alertbox. Thanks
But it's a harder way if you haven't ever created custom controls (not a big trick really).
The second way is also possible. really it's OK if you just need to know if something changed - just set some global isDirty = true. But if you need to keep track of what controls changed - you need to set some dictionary or any other collection for controls that were changed. And don't forget to clear after you don't need it. (I wouldn't go this way).