How to subscribe to EventHandler of a private control outside of Form

Posted by randooom on Stack Overflow See other posts from Stack Overflow or by randooom
Published on 2010-06-05T16:35:24Z Indexed on 2010/06/05 16:42 UTC
Read the original article Hit count: 238

Filed under:
|
|

Hi all,

maybe my design is not good, or I don't see the obvious solution, but I want to subscribe to a buttonClick EventHandler of Form1 from outside form1.

For example I have a Controller and Form1 who are both instanced in the main function. Now I want to subscribe a function from Controller to the buttonClick event from Button1_Click in Form1. But the button1 is declarded private, so i can't do

form1->Button1->Click += gcnew EventHandler(controller->function)

Is there any way to get around this?

Ok I could write a setter or something in Form1, but is there any other solution?

I read some examples, but they are all calling events from within the same class so they don't address my specific problem.

© Stack Overflow or respective owner

Related posts about winforms

Related posts about events