当我有一个子从打开时,如何禁用主窗体 [英] How disable the main form when I have a sub-from open

查看:82
本文介绍了当我有一个子从打开时,如何禁用主窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在到处寻找,但是当子窗体打开时,我没有找到禁用主窗体的代码(我可能只是措辞不正确.就像您尝试单击打开文件时一样)在应用程序中,打开"会闪烁并发出声音.

I've been looking everywhere and I haven't found the code to disable the main form when sub form is open(I could be just wording it wrong. Just like when you're opening a file if you try click on the application the Open flashes and makes a sound.

当我处于非主要的第二种形式时,如何使应用程序禁用?

How do I make the application disable while I'm in the second form that isn't the main?

所以这是放置的位置,因为每个人都在问

So this is where place it since everyone is asking

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
    {
        New_File newFile = new New_File();
        if (newFile.ShowDialog() == DialogResult.OK)
        {

        }
    }

花16秒打开文件,外观如下:

Edit 2: Take 16 sec to open the file, and looks like:

自从您拿走了我所有的代表以来,我必须发布一个链接 http://puu.sh/aDBF4/9d7fd31926.png

Since you took all my rep I have to post a link http://puu.sh/aDBF4/9d7fd31926.png

我仍然不明白为什么当我没有ShowDialog时,你们为什么仍然对我不满意.

I still don't understand why you guys are still downvoting me when I didn't what a ShowDialog was..

推荐答案

如果要在主表单可见但处于禁用模式时显示子表单,请遵循以下代码:

If you want to show the sub-form while the main form is visible but in disable mode, just follow the code below:

subForm.ShowDialog(); //Shows both main and sub form , but the main form is not accessible .

但是,如果您想隐藏主窗体,请遵循以下示例:

But if you want to have your main form hidden, follow this example :

this.Hide(); //Hides the main form.
subForm.ShowDialog(); //Shows the sub form.
this.Show(); //Shows the main form again after closing the sub form.

这篇关于当我有一个子从打开时,如何禁用主窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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