Hi,

I'm designing a form and I'd like to know when a control has been
edited. I know how to get around this, by putting code behind every
control to see if theres a change and then set a flag, but thats a
waste of time and a lot of code to write.

I can see someone having a much more elegant solution, I just can't
work it out. I was thinking of having every control inherit some
master control so I can have one peice of code that 'detects' when a
change has been made to any field or check box, just not sure how to
go about it.

Anyone have a nice and simple solution?

Thanks,

Re: Detecting changes on a form by Stoitcho

Stoitcho
Wed Apr 25 08:17:33 CDT 2007

Hi,

I don't think there is more elegant solution. Usually you are interested in
changes in some of the properties, not all of them and these properties
should fire an event when they change. Most if the base properties of the
control already fire events, however these are separate events, so to to
have one method handling all the changes require writing a code also.


The bottom line is up to you to deside which events your are interested of
and to write all the necessery code.


--
Stoitcho Goutsev (100)

"Sir Psycho" <panuccio.vince@gmail.com> wrote in message
news:1177504335.208055.206370@t39g2000prd.googlegroups.com...
> Hi,
>
> I'm designing a form and I'd like to know when a control has been
> edited. I know how to get around this, by putting code behind every
> control to see if theres a change and then set a flag, but thats a
> waste of time and a lot of code to write.
>
> I can see someone having a much more elegant solution, I just can't
> work it out. I was thinking of having every control inherit some
> master control so I can have one peice of code that 'detects' when a
> change has been made to any field or check box, just not sure how to
> go about it.
>
> Anyone have a nice and simple solution?
>
> Thanks,
>



Re: Detecting changes on a form by Kevin

Kevin
Wed Apr 25 09:01:06 CDT 2007

You're not thinking fourth-dimensionally!

A Control is never edited. A Control is a user interface element which
connects the user to the application. For example, in Microsoft Word, there
are literally thousands of Controls. But there is only one Document. Word
tracks the Document, not the Controls, to determine whether the Document is
"dirty" (needs saving) or not. So, assuming that your application allows
users to change some object, all you need to do is keep track of changes to
the object. This may involve creating a class that provides a programming
interface to the object, and having the class implement a "dirty" value when
it makes changes to the object ("Document"). Your Controls then simply talk
to the class, which handles all the "dirty" work.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Sir Psycho" <panuccio.vince@gmail.com> wrote in message
news:1177504335.208055.206370@t39g2000prd.googlegroups.com...
> Hi,
>
> I'm designing a form and I'd like to know when a control has been
> edited. I know how to get around this, by putting code behind every
> control to see if theres a change and then set a flag, but thats a
> waste of time and a lot of code to write.
>
> I can see someone having a much more elegant solution, I just can't
> work it out. I was thinking of having every control inherit some
> master control so I can have one peice of code that 'detects' when a
> change has been made to any field or check box, just not sure how to
> go about it.
>
> Anyone have a nice and simple solution?
>
> Thanks,
>



Re: Detecting changes on a form by Sir

Sir
Tue May 01 10:14:18 CDT 2007

I know what you mean Kevin, however your assuming all applications are
like Word :)

Take the options dialog box in word, there are litterally hundreds of
options to choose from. If I chance the dictionary from English to
Spanish, the Apply button magically enables itself. It knows changes
have been made and that the options need to be saved.

I think the solution may a combination of Stoitchos idea, too loop
through all the controls on a form and to inherit the existing winform
controls and add a dirty property to each one. This would save me a
lot of coding and i could loop through each one.

Thanks for your thoughts :-)




On Apr 26, 12:01 am, "Kevin Spencer" <unclechut...@nothinks.com>
wrote:
> You're not thinking fourth-dimensionally!
>
> A Control is never edited. A Control is a user interface element which
> connects the user to the application. For example, in Microsoft Word, there
> are literally thousands of Controls. But there is only one Document. Word
> tracks the Document, not the Controls, to determine whether the Document is
> "dirty" (needs saving) or not. So, assuming that your application allows
> users to change some object, all you need to do is keep track of changes to
> the object. This may involve creating a class that provides a programming
> interface to the object, and having the class implement a "dirty" value when
> it makes changes to the object ("Document"). Your Controls then simply talk
> to the class, which handles all the "dirty" work.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
>
> Printing Components, Email Components,
> FTP Client Classes, Enhanced Data Controls, much more.
> DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net
>
> "Sir Psycho" <panuccio.vi...@gmail.com> wrote in message
>
> news:1177504335.208055.206370@t39g2000prd.googlegroups.com...
>
> > Hi,
>
> > I'm designing a form and I'd like to know when a control has been
> > edited. I know how to get around this, by putting code behind every
> > control to see if theres a change and then set a flag, but thats a
> > waste of time and a lot of code to write.
>
> > I can see someone having a much more elegant solution, I just can't
> > work it out. I was thinking of having every control inherit some
> > master control so I can have one peice of code that 'detects' when a
> > change has been made to any field or check box, just not sure how to
> > go about it.
>
> > Anyone have a nice and simple solution?
>
> > Thanks,



Re: Detecting changes on a form by Kevin

Kevin
Tue May 01 13:09:03 CDT 2007

> Take the options dialog box in word, there are litterally hundreds of
> options to choose from. If I chance the dictionary from English to
> Spanish, the Apply button magically enables itself. It knows changes
> have been made and that the options need to be saved.

What makes you think that the localization properties of a Word document are
not properties of the Word document? All the interface does is change the
property of the document. The document object then sets its' "Dirty"
property to true.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Sir Psycho" <panuccio.vince@gmail.com> wrote in message
news:1178032458.616089.178590@u30g2000hsc.googlegroups.com...
>I know what you mean Kevin, however your assuming all applications are
> like Word :)
>
> Take the options dialog box in word, there are litterally hundreds of
> options to choose from. If I chance the dictionary from English to
> Spanish, the Apply button magically enables itself. It knows changes
> have been made and that the options need to be saved.
>
> I think the solution may a combination of Stoitchos idea, too loop
> through all the controls on a form and to inherit the existing winform
> controls and add a dirty property to each one. This would save me a
> lot of coding and i could loop through each one.
>
> Thanks for your thoughts :-)
>
>
>
>
> On Apr 26, 12:01 am, "Kevin Spencer" <unclechut...@nothinks.com>
> wrote:
>> You're not thinking fourth-dimensionally!
>>
>> A Control is never edited. A Control is a user interface element which
>> connects the user to the application. For example, in Microsoft Word,
>> there
>> are literally thousands of Controls. But there is only one Document. Word
>> tracks the Document, not the Controls, to determine whether the Document
>> is
>> "dirty" (needs saving) or not. So, assuming that your application allows
>> users to change some object, all you need to do is keep track of changes
>> to
>> the object. This may involve creating a class that provides a programming
>> interface to the object, and having the class implement a "dirty" value
>> when
>> it makes changes to the object ("Document"). Your Controls then simply
>> talk
>> to the class, which handles all the "dirty" work.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>>
>> Printing Components, Email Components,
>> FTP Client Classes, Enhanced Data Controls, much more.
>> DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net
>>
>> "Sir Psycho" <panuccio.vi...@gmail.com> wrote in message
>>
>> news:1177504335.208055.206370@t39g2000prd.googlegroups.com...
>>
>> > Hi,
>>
>> > I'm designing a form and I'd like to know when a control has been
>> > edited. I know how to get around this, by putting code behind every
>> > control to see if theres a change and then set a flag, but thats a
>> > waste of time and a lot of code to write.
>>
>> > I can see someone having a much more elegant solution, I just can't
>> > work it out. I was thinking of having every control inherit some
>> > master control so I can have one peice of code that 'detects' when a
>> > change has been made to any field or check box, just not sure how to
>> > go about it.
>>
>> > Anyone have a nice and simple solution?
>>
>> > Thanks,
>
>