Parent to Dll form problems
Hi there.
I have a problem with the parenting in C#. It seems as though I'm missing something. (Searching the web doesn't help).
I want to open multiple forms in a panel on my main form by clicking on a button, but I seem to be doing something wrong. This is the code I'm using:
public IntPtr Handel1;
public Control pannelControl;
private void button1_Click(object sender, EventArgs e)
{
pannelControl = panel1;
Handel1 = pannelControl.Handle;
FORM2 form2 = new FORM2();
form2.TopMost = false;
panel1.Controls.Add(form2);
form2.Show();
}
public partial class FORM2 : Form
{
public void FORM2_Load(object sender, EventArgs e)
{
}
}
First of all, The form is empty. This is the exception I'm getting at the line "panel1.Controls.Add(form2);"
ArgumentException was unhandled
Value does not fall within the expected range.