关于Windows窗体的打开和关闭 [英] Regarding Windows Form opening and closing

查看:56
本文介绍了关于Windows窗体的打开和关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在单击菜单项时调用了form1 show函数.打开form1时,单击确定"按钮,我将使用实例打开另一个form2并关闭form1.
但是问题在于,当打开form2并关闭form1时,form2会最小化.我不希望这种情况发生,我什至尝试禁用form2最小化按钮.

这是我的代码的示例:

Hi,

I am calling a form1 show function at a menu item click. When the form1 opens, on OK button click, I am opening another form2 using an instance and closing the form1.
But the problem is that when form2 opens and form1 closes, the form2 gets minimized. I dont want that to happen, I even tried disabling the form2 minimized button.

here is a sample of what my code looks like:

MenuItemClick()
{
    Form1 frm1 = new Form1;
    frm1.show();
}
///this displays Form 1

Form1Button_OK_Click()
{
  Form2 frm2 = new Form2();
  frm2.show();
  this.hide();////(Form1)
}



当我这样做时,form1确实关闭了,但是form2最小化了.我希望Form2出现在屏幕上.有人可以帮我吗?

谢谢



When I do this, the form1 does close, but the form2 minimizes.I want Form2 to be up on the screen. Can anyone help me on this?

Thanks

推荐答案

采取三种形式

Formmain,Formfirst,Formsecond

Take three forms

Formmain, Formfirst,Formsecond

public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
            FormFirst frs = new FormFirst();
            frs.Show();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {

        }
    }



在Formfirst的确定"按钮中,单击以下内容



In the Formfirst ok button click write below

public partial class FormFirst : Form
   {
       public FormFirst()
       {
           InitializeComponent();
       }

//Below is the button click of formfirst

       private void button1_Click(object sender, EventArgs e)
       {
           FormSecond fs = new FormSecond ();
           fs.Show();
           this.Hide();

       }
   }


这篇关于关于Windows窗体的打开和关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆