Liz wrote:
[...]
This *does* work, but there is at least one shortcoming, which is that if
the user changes a control and then undoes the change, I'm not detecting
that ... also, I'm just wondering if there's a better, more straightforward
way of handling the issue ... any other ideas out there?
Personally, I think the way you're doing it now is actually reasonably
elegant. It's not uncommon at all for a UI to consider any change, even
if it's eventually manually reversed by the user, to be considered a
"change".
That said, it appears to me that you're only actually look at changes to
text fields. So what you're really interested in is whether the text in
the text field is the same.
It seems to me that this would not actually be difficult to implement.
After all of the fields have been initialized, just add all of the
values to a Dictionary<object, stringwhere the control reference is
the key and the Text property value is the value.
Then when you are making the decision as to whether to prompt the user
to discard their changes, run through all the controls again except this
time compare the value in the dictionary with the current value.
If none of the text values are different, then you can safely suppress
the prompt.
Pete