I have a Parent form and i like to open a child form within the the parent form.
Can this be done? If yes please reply me with sample code .
Thanks !
There are two common ways to call a form from another form within Dynamics 365 for Finance and Operations. You can use a menu item button. Or you can use use X++ code to call another form. In this article I will show you how to use an Menu Item Button.
Following is the code to do what you want:
Assume that button1 is in the parent form.
private void button1_Click(object sender, EventArgs e)
{
this.IsMdiContainer = true;
Form Form2 = new Form();
Form2.MdiParent = this;
Form2.Show();
}
Also the following link will provide you more better details of what you want to do:
http://www.codeproject.com/KB/cs/mdiformstutorial.aspx
Hope this helps...
I note that all the answers here assume the OP intended to use MDI Form architecture, although that's never explicitly stated.
And there is another way a Form can be made a 'Child' of another Form: by simply setting its 'TopLevel property to 'False, and then setting its 'Parent property to the other Form.
Form2 f2 = new Form2();
f2.TopLevel = false;
f2.Parent = someOtherForm;
f2.Show();
By the way I think the whole idea of 'Forms within Forms' is a BAD idea, and MDI Architecture is now, justifiably, deprecated by MS.
Much better, I believe, to make secondary Forms 'Owned, and if you must have other Containers inside a Form, use UserControls, Panels, etc.
It depends on what you mean by "within the form". If you need to have the child form shown as a control of the parent form I guess you could try ParentForm.Controls.Add(new ChildForm())
. Or maybe even place the child form in an existing container in the parent form by again using the containing control's Controls
collection.
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With