Step 1: in Form 2
Define Delegation
Define events
Public Delegate VoidChange (StringNewsendemails );//The definition of Delegate and delegate should be the same as the actual method in the UIPublic EventChange mychangeevent;//Define events
In a method or event
Execution event
Mychangeevent (sb. tostring ());//Execution event
Step 2: in Form 1
Define a method (event execution method) that corresponds to the form parameter and return value of Form 2 Delegate)
//Event execution MethodPublic VoidSetsendemail (StringNewemails ){This. Textboxsendemaillist. Text =Newemails ;}
Register events in Load
Private VoidButtonsendemailsum_click (ObjectSender, eventargs e) {formsendemailsift fromsendemailsift=NewFormsendemailsift (This. Qqentitylist); fromsendemailsift. mychangeevent+ =NewFormsendemailsift. Change (setsendemail );//Register an eventFromsendemailsift. Show ();}
In this way, you can click a button in Form 2 or execute a method in Form 1 to execute the method you want.CodeNow
To directly pass values in different forms