Change Monitor

Is there any simple ways to monitor a forms control and all of its subcontrols for changes made to the containing text.
Ex. A form has a tabcontrol containing multiple textboxes.  If any one of the textboxes values change, I would like to set a boolean variable accordingly.  Is there any approaches that are suggested to this???????

Thanks,
Kendal
gvector1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NipNFriar_TuckCommented:
You can use the OnChange event, which can be set through the properties on the form or you can add it... you can also forward the event... for example

MyForm has YourForm has YourText....

public class MyForm : From {
    private bool hasTextChanged = false;

    public MyForm() {
        Form YourForm = new YourForm();
        YourForm.OnTextChanged += new EventHandler( YourForm_TextChanged );
    }
    private void YourForm_TextChanged( object sender, EventArgs args ) {
        hasTextChanged = true;
    }
}

HTH
0
gvector1Author Commented:
Doesn't the ontextchanged event only get triggered if the text property of the form is changed??????  My specific incident has a tabcontrol.  If any of the textboxes, belonging to the tabcontrol, text properties changes I would like to set the boolean variable.  Because of your suggestion, I though of having a single event and pointing each textboxes textchanged event to that one event.  Do you have any other suggestions??????

Thanks,
Kendal
0
NipNFriar_TuckCommented:
That is where I was leading to...  Basically when you create the tabcontrol you could register for the event at that time... so the same event handler would be listening to all the possible events for the textchange.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

gvector1Author Commented:
Wouldn't I still have to point each textbox's textchanged event to that one event?????????
0
NipNFriar_TuckCommented:
No ... only to the event handler... for instance lets say you have 5 tabs and on each tab you have 5 test boxes... inside a method you could do this...

public static _TextChanged( object sender, EventArgs ea ) {
   // do something for the text change...
}

Then for each textbox that you add that you want to monitor in the properties you set the OnTextChange to MyEventHandler...  Regardless of the
tab the textbox is on... note you should put this static method on the form that contains the tab control..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gvector1Author Commented:
Yes, so for instance.  On the form designer, for each textbox, I set the OnTextChange event to actually trigger the MyEventHandler method.  Is that correct?????
0
NipNFriar_TuckCommented:
Yes, I believe that that should work...
0
gvector1Author Commented:
Thanks for the assistance.
The points are yours.

Thanks,
Kendal
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.