目标是单击 FORM4 中的 Button1,然后允许 FORM1 中的 WebBrowser1 导航到该站点。
我不断收到此错误:错误 1 'NO1.Form4' 不包含采用 0 个参数的构造函数
表格 1
Form4 mForm;
private void button92_Click(object sender, EventArgs e)
{
if (mForm == null)
{
mForm = new Form4();
mForm.FormClosed += new FormClosedEventHandler(mForm_FormClosed);
mForm.Show();
}
else
{
if (mForm.WindowState == FormWindowState.Minimized)
mForm.WindowState = FormWindowState.Normal;
mForm.Focus();
}
}
void mForm_FormClosed(object sender, FormClosedEventArgs e)
{
mForm = null;
}
表格 4
public partial class Form4 : Form
{
private Form1 m_parent;
public Form4(Form1 frm1)
{
InitializeComponent();
m_parent = frm1;
}
private void button1_Click(object sender, EventArgs e)
{
m_parent.webBrowser1.Navigate("google.com");
}
private void Form4_Load(object sender, EventArgs e)
{
}
}