CodePudding user response:
Form2 defines an event, form1 subscription form2 event, when form2 event trigger form1 can perform the corresponding operationCodePudding user response:
Form2 code
The public event ActionMesEventHandler;
Private void button1_Click (object sender, EventArgs e)
{
MesEventHandler? Invoke (" OK ");
}
CodePudding user response:
Form1 code
Private void button4_Click (object sender, EventArgs e)
{
Form2 f2=new Form2 ();
F2. MesEventHandler +=F2_MesEventHandler;
F2. The Show ();
}
Private void F2_MesEventHandler (string obj)
{
MessageBox. Show (obj);
}