??????C#?????????????????????????????????????細?????????C#?и?????????С?
????Ч?????????????????壬FORM1????????“??form2”??button???????FORM2????????“???form1???“??button?????????????FORM1?е??button???“??form2””?FORM2????????????FORM2?е?“???form1???”??Form1????????
?????????Form2???棺
?????????????????к???????
????Form2????
????public delegate void ChangeFormColor(bool topmost);
????Form2????
????public event ChangeFormColor ChangeColor;
????Form2????????е??????
rivate void button1_Click(object sender?? EventArgs e)
{
ChangeColor(true);//?????????
}
??????????Form1???棺
????button???“??form2“??click???????????????
{
Form2 f = new Form2();
f.ChangeColor += new ChangeFormColor(f_ChangeColor);
f.Show();
}
f.ChangeColor += new ChangeFormColor(f_ChangeColor);
?????????????????+=?????????Tab????????????????????????????£?
void f_ChangeColor(bool topmost)
{
this.BackColor = Color.LightBlue;
this.Text = "?????";
}
????????????????
using System;
using System.Drawing;
using System.Windows.Forms;
namespace ?細???????
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender?? EventArgs e)
{
Form2 f = new Form2();
f.ChangeColor += new ChangeFormColor(f_ChangeColor);
f.Show();
}
void f_ChangeColor(bool topmost)
{
this.BackColor = Color.LightBlue;
this.Text = "?????";
}
}
}
using System;
using System.Windows.Forms;
namespace ?細???????
{
public delegate void ChangeFormColor(bool topmost);
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public event ChangeFormColor ChangeColor;
private void button1_Click(object sender?? EventArgs e)
{
ChangeColor(true);//?????????
}
}
}