i want to open multiple instances of one form and display it in another form or paenel of another form. how to do it
If you're not using MDI, you can still add a form to another form, or to a panel on a form.
public Form1()
{
InitializeComponent();
Form2 embeddedForm = new Form2();
embeddedForm.TopLevel = false;
Controls.Add(embeddedForm);
embeddedForm.Show();
}
You will need to set the FormBorderStyle
to None
, unless you want to have an actual movable form inside your form.
If you want to do this to create a reusable "template" to use in multiple forms, you should consider creating a user control instead. Not to be confused with a custom control, which is intended for when you need to do your own drawing instead of using collections of standard Windows controls.
I'm not entirely sure what your intentions are, but MDI (as mentioned in one of the other answers) might actually be what you're looking for.
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