如何在处理子表单时隐藏父表单? [英] How to hide a parent form while working on the child form?

查看:108
本文介绍了如何在处理子表单时隐藏父表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个项目,包括通过MDI表单存储员工记录。

现在选择添加新按钮后,我希望第二个子表单处于活动状态,而第一个(父表单)表格暂时被禁用。



我试图使用showdialog()方法,但由于其MDI格式,它显示错误说明显示的表单不是顶级窗口。

如果在mdi条件下这是不可能的,

我可以做什么来执行相同的操作。

I am making a project that consists of storing employee records through MDI forms..
Now after selecting Add New Button, I want the second child form to be active and the first (parent form)form to be disabled for the time being.

I've tried to use the showdialog() method, but due to its MDI form, its shows an error stating "The form being shown is not a top-level window."
If this is not possible in mdi conditions,
what is it that I can do to execute the same.

推荐答案

错误信息是正确的:MDI子窗体不能是模态的 - 这就是ShowDialog方法的用法。

如果您希望主窗口(MDI父窗口)在新窗口可见时消失,那么它不能是MDI子窗口,它必须是常规的顶级窗口 - 然后您只需执行此操作:

The error message is right: and MDI child form cannot be modal - which is what the ShowDialog method is there to do.
If you want the main (MDI parent) window to "disappear" while the new window is visible, then it can't be an MDI child window, it must be a regular "top level" window - and then you just do this:
Dim mnf As New MyNewForm()
Hide()
Dim result As DialogResult = mnf.ShowDialog()
Show()


这篇关于如何在处理子表单时隐藏父表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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