更改活动形式展现另一种形式 [英] change active form to show another form

查看:218
本文介绍了更改活动形式展现另一种形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Form1中,另外一个,我补充道。 Form1中正在起步的Program.cs运行。我需要一个按钮,按隐藏 Form1中并显示选项的形式。

I have a Form1 and another one that I added. Form1 is being run by program.cs at the start. I need to hide Form1 and show options form by the press of a button.

    private void submitPassword_Click(object sender, EventArgs e)
    {
        options optionForm = new options();
        optionForm.Show();
    }



上面的代码打开的选项之上形成的,但我需要它来代替当前表单。我怎样才能做到这一点?

the above code opens the options form on top, but I need it to replace the current form. how can I achieve this?

推荐答案

隐藏使用目前的形式 this.Close()显示出新的,并确保您使用的是无参数之前 Application.Run 这样的程序时不会关闭它的主窗体关闭。

Hide current form using this.Close() before showing new one and make sure you are using parameterless Application.Run so program won't close when you close it's main form.

这篇关于更改活动形式展现另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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