本文介绍了如何关闭form2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码将显示form2,但是我想要的是,当我单击列表框"close form 2"时
表格2将不会关闭!

this code wil show form2 but what i want is , when i click in listbox "close form 2"
the form 2 will not close !

private void button1_Click(object sender, EventArgs e)
{
Form2 myForm;
myForm = new Form2();
myForm.Show();
}





private void listBox5_Click_1(object sender, EventArgs e)
{
                   if (listBox5.Text == ("close form 2"))
                     {
                         


                         Form2 myForm;
                         myForm = new Form2();
                         myForm.close();// but its not close it D:
}
}

推荐答案


private Form2 myForm;
private void button1_Click(object sender, EventArgs e)
   {
   myForm = new Form2();
   myForm.Show();  
   }

private void listBox5_Click_1(object sender, EventArgs e)
   {
   if (listBox5.Text == ("close form 2"))
      {
      myForm.Close();
      }
   }



这篇关于如何关闭form2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:18