0

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.

John Nuñez
  • 1,780
  • 13
  • 35
  • 51

2 Answers2

3

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.

E.Z. Hart
  • 5,717
  • 1
  • 30
  • 24
  • I researched and I've noticed that i can't display a dialog inside a form MDi, but thank you for your time – John Nuñez Feb 20 '12 at 01:28
  • I must be misunderstanding the problem. I have a project right here with an MDI Form which has a child form, and there's a button on the child form which launches a modal dialog. Is that not what you're trying to do? – E.Z. Hart Feb 20 '12 at 01:46
  • I have a main form (MDI Parent), now into the mdi parent display and Child form and into this Child display a Dialog. : – John Nuñez Feb 20 '12 at 01:53
0

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.