Search code examples
vb.netformsmdiparent

ShowDialog with MdiParent Issue VB:NET


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.


Solution

  • 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.