MDIParent, MDIChild and MDI..ermmm..GrandChild? (How to set the MDIParent on a form that is called through a child form?)
-
Hi everyone, I have a little problem and I feel like the solution is in front of me but I just can't make it happen. I haven't googled it yet, just because i don't know how to search it, but I'm looking for it in the MSDN Forums (Searched MDI in forums and reading the topics whichever looks close to solution.) and I was unable to find something for the problem. The problem is I have an MDI form and I show a dialog which offers you some options and when the user clicks the button a new dialog appears.But I couldn't find a way to set the MDIParent property for the form that is called from the child.So the new form appears independent from the MDIParent. What I've tried is: I tried overloading the Form.Show(this.MDIParent) I've created an instance of the MDI form in the Grandchild(?) form. I've tried to set the this.MDIParent = MDIMain but it just didn't work. I've tried this.AddOwnedForm(Form) So, surprisingly, none of them worked. It'd be really nice if you could help me through or hold my hand and take me to the neverland. =) Thanks.
-
Hi everyone, I have a little problem and I feel like the solution is in front of me but I just can't make it happen. I haven't googled it yet, just because i don't know how to search it, but I'm looking for it in the MSDN Forums (Searched MDI in forums and reading the topics whichever looks close to solution.) and I was unable to find something for the problem. The problem is I have an MDI form and I show a dialog which offers you some options and when the user clicks the button a new dialog appears.But I couldn't find a way to set the MDIParent property for the form that is called from the child.So the new form appears independent from the MDIParent. What I've tried is: I tried overloading the Form.Show(this.MDIParent) I've created an instance of the MDI form in the Grandchild(?) form. I've tried to set the this.MDIParent = MDIMain but it just didn't work. I've tried this.AddOwnedForm(Form) So, surprisingly, none of them worked. It'd be really nice if you could help me through or hold my hand and take me to the neverland. =) Thanks.
hi there, i think this will help from the first form you have to raise an event (on click of something ex. button) and you write this code : Form frm = new Form(); frm.MdiParent = this; frm.Show(); and i will depend on that form, from where it was opened, respect.
spaps
-
hi there, i think this will help from the first form you have to raise an event (on click of something ex. button) and you write this code : Form frm = new Form(); frm.MdiParent = this; frm.Show(); and i will depend on that form, from where it was opened, respect.
spaps
Hi Shpends, Thanks for the quick reply. But it seems to me that your code shows up a child form.What I need is showing a child form that is called from the previous child. I mean, if we call the first child form X and second child form Y, I try showing Y through X and I can't set the MDIParent property because I call it from an MDIChild form not from the MDIParent itself. I hope the explanation above is clear enough. =) Thanks again.
-
Hi Shpends, Thanks for the quick reply. But it seems to me that your code shows up a child form.What I need is showing a child form that is called from the previous child. I mean, if we call the first child form X and second child form Y, I try showing Y through X and I can't set the MDIParent property because I call it from an MDIChild form not from the MDIParent itself. I hope the explanation above is clear enough. =) Thanks again.
Try this... In the MDIParent (Form1)
private void Form1_Load(object sender, EventArgs e)
{
Form2 newForm = new Form2(this);
newForm.MdiParent = this;
newForm.Show();
}for 1st Child (Form2)...
public Form2(Form mdiParent)
{
InitializeComponent();
_mdiParent = mdiParent;
}private Form \_mdiParent; private void Form2\_Load(object sender, EventArgs e) { Form3 newForm = new Form3(); newForm.MdiParent = \_mdiParent; newForm.Show(); }
with Form3 being the 2nd Child. Obviously you need to dispose of the forms somewhere but should get you going.
-
Try this... In the MDIParent (Form1)
private void Form1_Load(object sender, EventArgs e)
{
Form2 newForm = new Form2(this);
newForm.MdiParent = this;
newForm.Show();
}for 1st Child (Form2)...
public Form2(Form mdiParent)
{
InitializeComponent();
_mdiParent = mdiParent;
}private Form \_mdiParent; private void Form2\_Load(object sender, EventArgs e) { Form3 newForm = new Form3(); newForm.MdiParent = \_mdiParent; newForm.Show(); }
with Form3 being the 2nd Child. Obviously you need to dispose of the forms somewhere but should get you going.