Is it possible to add a form to a panel?
-
I don't think so... You should use a UserControl... HTH Shaun
-
zuhx wrote: Does any one know if it is possible to add a form to a panel? Yes, it is possible, but not really recommended unless you change the FormBorderStyle.
MyForm form = new MyForm();
form.TopLevel = false;
form.Location = new Point(5, 5);this.Controls.Add(form);
form.Show();The only two things you HAVE to do is set
TopLevel
to false, and callShow
. Don't forget that if the user clicks the close button on the form then the form object get's Dispose'd -- yet another reason to change the forms FormBorderStyle or at least hook the form's Closing event. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him -
zuhx wrote: Does any one know if it is possible to add a form to a panel? Yes, it is possible, but not really recommended unless you change the FormBorderStyle.
MyForm form = new MyForm();
form.TopLevel = false;
form.Location = new Point(5, 5);this.Controls.Add(form);
form.Show();The only two things you HAVE to do is set
TopLevel
to false, and callShow
. Don't forget that if the user clicks the close button on the form then the form object get's Dispose'd -- yet another reason to change the forms FormBorderStyle or at least hook the form's Closing event. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with himJames T. Johnson wrote: Yes, it is possible, but not really recommended unless you change the FormBorderStyle. I do need to change the FormBorderStyle. Can you give a little more detail on why it is not recommended? Is it only because of changing the FormBorderStyle or are there other reasons as well?
-
James T. Johnson wrote: Yes, it is possible, but not really recommended unless you change the FormBorderStyle. I do need to change the FormBorderStyle. Can you give a little more detail on why it is not recommended? Is it only because of changing the FormBorderStyle or are there other reasons as well?
zuhx wrote: Can you give a little more detail on why it is not recommended? I don't recommend adding a form to a panel UNLESS you change the border style. Otherwise you wind up with a form that can be moved around (not so bad if that is the intended purpose) but it can also be closed which can be a problem. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him