ShowDialog 与 MdiParent 问题 VB:NET

发布于 2025-01-06 18:37:51 字数 604 浏览 3 评论 0原文

实际上,我正在尝试显示和对话到父窗体,一个参考示例是:

Parent      Parent_child    dialog
Main_form   new_invoice     new_invoicedialog

我尝试了此代码,但它说:

Private Sub invoice_new_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp

            With new_invoicedialog
                .MdiParent = Main_Form
                .Owner = Me 'invoice_new
                .StartPosition = FormStartPosition.CenterScreen
                .ShowDialog()
            End With

End Sub

不是顶级窗体的窗体不能显示为模式对话框。在调用 showDialog 之前从任何父窗体中删除该窗体。

Actually i'm trying to show and dialog into a parent form, An reference example is:

Parent      Parent_child    dialog
Main_form   new_invoice     new_invoicedialog

I Tryed this code But it says:

Private Sub invoice_new_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp

            With new_invoicedialog
                .MdiParent = Main_Form
                .Owner = Me 'invoice_new
                .StartPosition = FormStartPosition.CenterScreen
                .ShowDialog()
            End With

End Sub

Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我最亲爱的 2025-01-13 18:37:51

我认为如果您删除 .MdiParent = Main_Form 它将起作用。您正在尝试显示模式对话框,这与 MDI 窗体不同。

I think if you remove .MdiParent = Main_Form it will work. You're trying to show a modal dialog, which isn't the same thing as an MDI form.

临走之时 2025-01-13 18:37:51

我知道这真的很晚了,但它可能会对其他可能遇到这个问题的人有所帮助,就像我在研究这个问题时所做的那样。您可以执行 smt 操作:

newTransaction.MdiParent = Me
Me.Enabled = False
newTransaction.Show()
Me.Enabled = True

它允许您仍然将表单作为子表单运行,但关闭父表单,直到子表单关闭,然后再次使其可用。

I know this is real late but it might prove helpful to someone else that may come across this as I did when researching this issue. You could do smt like:

newTransaction.MdiParent = Me
Me.Enabled = False
newTransaction.Show()
Me.Enabled = True

It allows you to still run the forma as a child but turns off the parent form until the child is closed, then it makes it available again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文