Click here to Skip to main content
15,891,906 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a form, called frmMain, which is a MDI container.

frmMain shows an instance of frmInventory. That instance then appears within frmMain. From a menu on frmInventory (that is added to frmMain's menu) I create an instance of frmAddComm.

However, frmAddComm is basically an add new item window, prompting for input data, which it then uses to create a new item to send back to frmInventory.

Try as I might, I cannot get frmAddComm to appear within the bounds of frmMain.

I have tried:

frmAddComm addComm = new frmAddComm();
addComm.MDIParent = this.Owner;  // this referring to frmInventory
addComm.Show();


and

frmAddComm addComm = new frmAddComm();
addComm.MDIParent = this.Owner;
addComm.ShowDialog();   // what I really want to use


and

frmAddComm addComm = new frmAddComm();
addComm.MDIParent = (MDIClent)this.Parent;
// addComm.ShowDialog;    // this throws and exception
addComm.Show();       // shows within bounds of frmMain


The last option however does not pause and wait for addComm.Close() to happen, and thus continues on right through my if statement to determine if OK or Cancel was pressed, thus defaulting to cancel.

For program functionality I have this:

frmAddComm addComm = new frmAddComm();

addComm.MdiParent = this.Owner;
addComm.ShowDialog();
if (addComm.DialogResult == DialogResult.OK)
{
   qc_Inventory.Add(addComm.NewCommunicator);
   ManageInventory(tabInventory.SelectedIndex);
}


However, it does not put addComm within the bounds of frmMain, which is what I want.
Posted
Updated 20-Oct-10 16:42pm
v2

1 solution

Have a look at this article:
http://www.codeproject.com/KB/dialog/MDIChildDialog.aspx[^]

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900