dgk,
| All these values are coming out of an object and going back into that
| object,
Oh! in the case where you have an "object" I would ask the object if any of
its values changed.
In my Property Set methods on my object I call a protected "SetDirty" method
that sets a boolean flag that indicates if the object is dirty. My "object"
then has a public readonly IsDirty property that the UI can use to decide if
its dirty or not. When an object is loaded or saved, the boolean flag is
cleared to indicate that the object itself is not dirty. Generally SetDirty,
IsDirty, and the boolean flag are part of a common base class.
| Essentially I'm trying to show a "Are you sure you want to discard
| your changes" type dialog if someone hits the cancel button after
....
| So I guess I have to
| implement my own code for this?
I would consider implementing a "Clone" method that returns a "copy" of the
current object, this method would use MemberwiseClone if a shallow copy was
acceptable, otherwise it would do a deep copy. Be careful on deep copies &
object hierarchies.
Alternatively I would consider having 2 fields for each property of my
"object", a current value & an original value. The "object" would have a
"Revert" method that would restore the current values to the "original"
values. When I load the object I would set both fields to the same value.
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"dgk" <No*****@MailsAnonymous.com> wrote in message
news:v2********************************@4ax.com...
| On Mon, 28 Nov 2005 08:56:34 -0600, "Jay B. Harlow [MVP - Outlook]"
| <Ja************@tsbradley.net> wrote:
|
| >Dgk,
| >I was answering the "What does the IsMirrored property tell me?"
question.
| >
| >It appears that your "I'm searching for a way to determine if control
values
| >have changed." question remains unanswered.
| >
| >Are you asking for any property in general, or a specific property, such
as
| >Text?
| >
| >I normally handle the TextBox.TextChanged event to determine when the
Text
| >property changed. There are similarly named events for their respective
| >properties. SizeChanged event for the Size property, TabIndexChanged
event
| >for the TabIndex property and so on. A lot of the properties/event pairs
are
| >actually inherited from Control.
|
|
| Essentially I'm trying to show a "Are you sure you want to discard
| your changes" type dialog if someone hits the cancel button after
| editing some data. I looked back in the newsgroup history and found a
| few good ideas, such as adding handlers to radio buttons so that as
| changes occur they set a boolean flag. I'm also recursively running
| through the form and containers on the form looking for controls that
| will tell me that they were edited.
|
| I'm not doing overkill here. If someone changes a value and then
| changes it back, that is still going to set the flag that something
| changed. Sort of sloppy I know but I'm under some time pressure here.
| Ha, who isn't?
|
| All these values are coming out of an object and going back into that
| object, so I suppose that I can do a copy of the object before editing
| and then load everything into another object and compare. I'm pretty
| sure that comparing the objects will just tell me whether the
| variables are pointing to the same object.
|
| I need to understand deep copy and shallow copy a bit better. Most of
| the object is pretty straight forward but there are a few collections
| in there. Actually they are generic lists. Do you know if a generic
| list is duplicated by a shallow copy or do I do a deep copy to get
| separate instances?
|
| Very odd. I just tried it on my object and I don't seem to have Copy,
| Clone, or anything like that. Oh, ok. I need to use memberwiseclone or
| something like that but it's protected. Rats. So I guess I have to
| implement my own code for this?
|
| Ah. Well, I look forward to any hints. So much to learn, so little
| time.