private void button1_Click(object sender, System.EventArgs e)
{
     if(textBox1.Text=="")
     {
this.Close();   //怎样写才能彻底关闭窗体
         this.dispose();
         return;
     }
     else
     {
MessageBox.Show("Can't be Closed!");
         return;
     }
     MessageBox.Show("Why and i style here!");  //程序为什么会运行这一句。
}

解决方案 »

  1.   

    在this.Close();下面加一句return;
    private void button1_Click(object sender, System.EventArgs e)
    {
             if(textBox1.Text=="")
    {
    this.Close();
    return;
    }
    else
    {
    MessageBox.Show("Can't be Closed!");
    }
    MessageBox.Show("Why and i style here!");  //程序为什么会运行这一句。
    }
      

  2.   

    會出現的.即使把它換成application.Exit();還是會執行最後一句;之後他會回到Main()
      

  3.   

    你可以this.点出窗口.Close();
    而且你textbox.text 获取什么你那里没有写啊!
    所以它会运行到下面的。如果IF成立它不会往下走的1
      

  4.   

    if(textBox1.Text =="")
    {
      this.Close();
      Application.Exit();
      return;
    }
    else
    {
      MessageBox.Show("Can't be Closed!");
    }
      MessageBox.Show("Why and i style here!");