public partial class Form2 : Form
{
MainForm f1;
public Form2(MainForm ff)
{
this.f1 = ff;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
f1.BackColor = System.Drawing.Color.Blue;
}
}
新建的窗口作为子窗口,主窗口调用时
public partial class MainForm: Form
{
public MainForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this);
f2.Show();
}
}
将自己传给子窗体即可