现有两个窗体,form1需要form2的方法
(1)在form2 中书写下列代码
class Form2: Form
{
public static Form2 frm2;//声明为静态
public Form2()//构造函数
{
InitializeComponent();
frm2 = this;
}
private void button1_Click(object sender, EventArgs e)//被调用的方法
{
}
(2)在form1 中写下列代码
Form2.frm2.Button;
Form2.frm2.button1_Click();//直接调用方法