ar.gorgin
ar.gorgin

Reputation: 5002

How allows ShowDialog in child of MdiContainer?

I have a form that this.IsMdiContainer = true. I show a child form in it.

 FrmCustomer frm=new FrmCustomer();
 frm.MdiParent = this;
 frm.Show();

I want to showdialog a form in FrmCustomer . I use this code,

  FrmCustomerDetail frm=new FrmCustomerDetail(null);
  frm.MdiParent = this.MdiParent;
  frm.ShowDialog();

but i get error,

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

Upvotes: 0

Views: 320

Answers (1)

Anu Viswan
Anu Viswan

Reputation: 18155

One way to do this would be to leave our the MdiOwner and set the Window Owner using ShowDialog method parameter.

   FrmCustomerDetail frm=new FrmCustomerDetail(null);
   frm.ShowDialog(this);

Upvotes: 1

Related Questions