سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top