ShowDialog with MdiParent Issue VB:NET

John Nuñez picture John Nuñez · Feb 20, 2012 · Viewed 7.1k times · Source

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.

Answer

E.Z. Hart picture E.Z. Hart · Feb 20, 2012

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.