窗体之间调用方法,参数等。(传窗体引用)
其实就是传 this
窗体A:
public partial class FormA : Form
{
public FormA()
{
InitializeComponent();
}
public void AAA()
{
MessageBox.Show("来自A窗体的方法");
}
private void button1_Click(object sender, EventArgs e)
{
FormB bFrm = new FormB(this);
bFrm.Show();
}
}
窗体B:
public partial class FormB : Form
{
FormA aFrm;
public FormB(FormA frm)
{
InitializeComponent();
this.aFrm = frm;
}
private void button1_Click(object sender, EventArgs e)
{
this.aFrm.AAA();
}
}
本文出自 小古Blog,转载时请注明出处及相应链接。
本文永久链接: http://blog.chdz1.com/?post=150