Home > Net >  How to put the Form2 input data back to the _click (can't use the Internet, first open Form1 an
How to put the Form2 input data back to the _click (can't use the Internet, first open Form1 an

Time:09-17

Text editor, for example, use first open RichTextBox Form1, next reoccupy Form2 to enter search string, Form1 received Form2 comes back data and then put the string corresponding ash (highlighted),

CodePudding user response:

Form2 defines an event, form1 subscription form2 event, when form2 event trigger form1 can perform the corresponding operation

CodePudding user response:

Form2 code
 
The public event Action MesEventHandler;

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);
}
  •  Tags:  
  • C#
  • Related