我写得程序中有几个Form,想对一个Form操作完后让它自动关闭,如何实现?

解决方案 »

  1.   

    操作完后加上this.Close()不就行了吗?
      

  2.   

    Form操作完后让它自动关闭,如何实现?那就在操作完成后加上一句,this.close();
      

  3.   

     private void button1_Click(object sender, EventArgs e)
            {
                //“确定按钮”
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("输入登录信息不完整,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information );
                }
                else
        
                {
                    if ((textBox1.Text == "admin") & (textBox2.Text == "12345"))
                    {
                        MessageBox.Show("登录成功,O(∩_∩)O~","信息提示",MessageBoxButtons.OK,MessageBoxIcon.None);
                        //this.Close();
                        table010 myf1 = new table010();
                        myf1.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码不正确,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }        }
    程序如上,加上this.close();后新的窗口也随即消失,能否只让原来的登录窗口消失,但是新窗口不消失?谢啦!
      

  4.   


    private void btn_nextForm_Click(object sender, EventArgs e)
            {
                nextForm nfrom=new nextForm();
                nform.Show();//显示下一个窗口
                this.Close();//关闭当前窗口
                 /*
                this. Hide();//隐藏当前窗口
               */
            }
      

  5.   

    show本窗体时候用showdialogue,当关闭时只关闭本窗体
      

  6.   

    不用this.close();需要关闭那个窗口就form_n.close();即关闭你这个登陆界面的form
      

  7.   

    foreach (Form form in Application.OpenForms)
    {
          form.Close();
    }
      

  8.   

    别关主窗体了,直接this.hide();这样登录进去主窗体就没了
      

  9.   


    先this.Close();
    再Show新的窗体撒^^
      

  10.   

     for (int i = Application.OpenForms.Count - 1; i > -1; i--)
     {
             Application.OpenForms[i].Close();
     }
      

  11.   

    this.hide(); 这个可以达到你的要求.
    但是在关闭的时候要用Application.Exit();如果用this.close()的话,那么进程里面还会存在.
      

  12.   

    你可以这样呀。要运行 shutdown -s -t 0 就可以呀。所有form都关闭了呀
      

  13.   

    你是想登陆成功后让登陆窗体消失,主窗体出现吧,好像是需要把登陆窗体隐藏,用this.Visable=fase;就可以了。如果想让主窗体关闭后,再让登陆窗体出现,则需要从主窗体传个值过来,让登陆窗体的Visable变成true就好了。
      

  14.   

    如果是关闭当前操作窗体的话就是this.close();
    如果想关闭整个应用程序的话(当有多个窗体时),使用Application.Exit();具体情况具体分析拉!.