ShowDialog 与 MdiParent 问题 VB:NET
实际上,我正在尝试显示和对话到父窗体,一个参考示例是:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为如果您删除
.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.我知道这真的很晚了,但它可能会对其他可能遇到这个问题的人有所帮助,就像我在研究这个问题时所做的那样。您可以执行 smt 操作:
它允许您仍然将表单作为子表单运行,但关闭父表单,直到子表单关闭,然后再次使其可用。
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:
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.