日期:2014-05-17 浏览次数:20842 次
private void MDILogin_Click(object sender, EventArgs e)
{
if (Login == null || Login.IsDisposed)
{
MDILogin.Visible = false;
Login = new Login();
Login.Owner = this;
Login.ShowDialog();
}
else
{
Login.Owner = this;
Login.ShowDialog();
}
private void Login_FormClosing(object sender, FormClosingEventArgs e)
{
Button MLogin = ((MDIBOX)this.Owner).Controls["MDILogin"] as Button;
MLogin.Visible = true;
}
private void Button1_Click(object sender, EventArgs e)
{
Login f2 = new Login();
f2.ShowText += new Form2.ParentShowText(ShowText_Method);
MDILogin.visable=false;
f2.Show();
}
Form1不一定是Form2的主窗体
然后在Form1中写一个实现的公共的事件
public void ShowText_Method()//参数与Form2中的委托对应起来
{
//根据Form2中的传参,实际是在Form1中操纵细节
MDILogin.visable=true;
}
在Form2中的X的点击事件
private void FormClosing_Click(object sender, EventArgs e)
{
ShowText();
}