如何设置父窗体中某控件的属性
我的主窗体(frmMain)中有一个expandableSplitter1控件,还有一个panel1控件,我把子窗体(subForm)嵌入到panel1中,现在我想在用户关闭panel1中内嵌的subForm时能够将主窗体中的expandableSplitter1.Expanded属性设置成true。我已经将expandableSplitter1的Modifier设置成Public了。现在subForm的父窗体应该是panel1,而panel1的父窗体应该是frmMain。请问:我在subForm的窗体关闭事件代码应该如何写才能实现此功能?谢谢!
------解决方案--------------------form2.SetParameter(strSqlPath, this); //传参
private Form1 mw_Form;
public void SetParameter(string strConn, Form1 _form)
{
mw_Form = _form;
}
------解决方案--------------------在主画面中:
private void simpleButton2_Click(object sender, EventArgs e)
{
Form form = new Form();
...
form.FormClosed += new FormClosedEventHandler(form_FormClosed);
...
}
void form_FormClosed(object sender, FormClosedEventArgs e)
{
expandableSplitter1.Expanded = true;
}