public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.a += F_a1;
// f.Wt = (string a, string b) => { this.Text = a; }; //setText;
f.ShowDialog();
}
private void F_a1(object sender, EventArgs e)
{
this.Text = (e as Myevent).names ;
button2.Text = (e as Myevent).names;
}
void setText(string a,string b ){
this.Text = a;
}
private void button2_Click(object sender, EventArgs e)
{
}
public partial class Form2 : Form
{
public delegate void wt(string a, string b);
public event EventHandler a;
public wt Wt;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (Wt != null)
{
Wt(textBox1.Text, "aa");
}
if (a != null)
{
a(this, new Myevent() { names = textBox1.Text });
}
}
}
public class Myevent : EventArgs
{
public string names { get; set; }
}