tags:

views:

49

answers:

1

how do I trigger another control's method? I have a function that can be terminated by clicking a button but the program can also run to completion. Since the termination logic is the same regardless of how the function ends I'd just like to trigger the termination logic on the stop button.

+3  A: 

Just call the controls method as you would any other - you can pass the sender & event args from the stop button as the method arguments for the other control.

Or, move the common code in to a private method which both control methods then call.

If the logic in question is more than basic processing you should consider refactoring it out in to its own class any way to keep you GUI nice and simple and your code reusable.

Chris W
the latter is preferred
Steven A. Lowe