How to subscribe to EventHandler of a private control outside of Form
- by randooom
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.