Click to See Complete Forum and Search --> : Mdi parent problem!!!!!


placebo87
January 24th, 2009, 06:53 AM
When i try to open the menu in a midi form it tells me this:


System.ArgumentException: Form that was specified to be the MdiParent for this form is not an MdiContainer.
Parameter name: value
at System.Windows.Forms.Form.set_MdiParentInternal(Form value)
at System.Windows.Forms.Form.set_MdiParent(Form value)
at Gym.Form1.membersToolStripMenuItem_Click(Object sender, EventArgs e) in d:\projekt\gym\gym\gym\form1.h:line 158



Here is the Form1 Code:


private: System::Void membersToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
for each(Form^ childform in this->MdiChildren)
childform->Close();
Form2^ instance=gcnew Form2();
instance->MdiParent= this;
instance->Show();
}

And Form 2:


private: System::Void Form2_Load(System::Object^ sender, System::EventArgs^ e) {
String^ conString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source=..\\db.mdb";

OleDbConnection^ connection=gcnew OleDbConnection(conString);

String^ queryString="SELECT * From members";

OleDbDataAdapter^ adapter=gcnew OleDbDataAdapter(queryString,connection);

DataSet^ memb=gcnew DataSet();

adapter->Fill(memb,"members");

dataGridView1->DataSource=memb->Tables[0];

}






WHATS THE PROBLEM PLEASE HELP QUICK PLEASE

Alex F
January 24th, 2009, 08:35 AM
Using Windows Forms Designer, set Form1 property IsMdiContainer to true.

placebo87
January 24th, 2009, 09:10 AM
Thanks Alex F...

Marc G
January 25th, 2009, 09:54 AM
[ moved thread ]

NOTE: Please use code tags when posting code like: [code] your code [/code]