[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

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
0
gvector1
Asked:
gvector1
  • 4
  • 4
1 Solution
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now