我有两个窗体form1和form2
程序运行时运行form1
用form1登陆到form2   同时隐藏了form1
我要如何才能在关闭form2的时候把隐藏了的form1显示出来,同时将其中的用户名和密码清空?

解决方案 »

  1.   

    方法很多。
    可以在form1订阅form2的formClosed事件,在响应事件时:  this.两个textbox.text清空,再 this.show()
      

  2.   

    我的方法:
    将form2的tag设为form1,然后就可以干想干的事了
      

  3.   

    //在Form1登录 确认的按钮事件:
    private void button1_Click(object sender, System.EventArgs e)
    {
    if(通过密码验证)
    {
    this.Hide();
    Form2 f2=new Form2();
    f2.ShowDialog();
    this.textBox1.Text="";
    this.textBox2.Text="";
    this.Show();
    }
    }
      

  4.   


            private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm = new Form2();
                frm.FormClosed += delegate(object obj, FormClosedEventArgs args)
                {
                    this.Show();
                };
                frm.Show();
                this.Hide();
            }
      

  5.   

    你在form1中new fomr2时把form1的引用传过去form2 f2 = new form2(this);然后form2中可以对form1进行操作
      

  6.   

    具体点:
    form1登录按钮事件中:form2 f2 = new form2(this);
    f2.show();
    this.Hide();或this.visable=false;form2中:
    public form1 f1;
    //构造方法
    public form2(form1 _f1)
    {
       f1=_f1;
    }那么你在form2中即可用f1来对form1操作
    你可以f1.visable =true;
      

  7.   

    这没什么难的啊,
    在form1--->form2中的某个连接按钮中写
    this.Hide();
    Form2 f2=new Form2();
    f2.ShowDialog();
    this.textBox1.Text="";
    this.textBox2.Text="";
    在form2--->form1中Form2_closing事件中写
    Form1 f1=new Form();
    f1.ShowDialog();
    方法很多的,楼上有好多