Identifying if values on a form change

  • Thread starter Thread starter Jeff Williams
  • Start date Start date
J

Jeff Williams

I have a windows form which contains various controls like textboxes,
comboboxes, checkboxes etc.

When the user clicks the ok button I would like to determine if the data
has changed in one or more of this controls.

What is the easiest way to find this information out.

If data is changed I will update the record. If no I will just ignore
the update.

Regards
Jeff
 
Jeff Williams said:
I have a windows form which contains various controls like textboxes,
comboboxes, checkboxes etc.

When the user clicks the ok button I would like to determine if the data
has changed in one or more of this controls.

What is the easiest way to find this information out.

If data is changed I will update the record. If no I will just ignore the
update.

I've done this in the past as follows:
When loading the form, I loop recursively through the Controls collection
finding all the controls that are of one of the types whose changes I want
to monitor. For each of these controls, I connect its Change event to a
common method in the form (one for each kind of change event, since the
EventArgs is not the same for all the kinds of control). This method sets a
flag when it detects a chage, and this flag is what I monitor for changes
when closing the form.
 
Alberto Poblacion said:
I've done this in the past as follows:
When loading the form, I loop recursively through the Controls
collection finding all the controls that are of one of the types whose
changes I want to monitor. For each of these controls, I connect its
Change event to a common method in the form (one for each kind of change
event, since the EventArgs is not the same for all the kinds of control).
This method sets a flag when it detects a chage, and this flag is what I
monitor for changes when closing the form.
And in addition to this you can disable your OK button until a change has
been made. This will provide the user with an indicator that they have made
a change.

PS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top