H
harishashim
I'll make this post as short as possible.
1. Put a GroupBox on a window form. Put a Button and TextBox inside the
GroupBox .
2. Select the group box, do copy and paste inside the same windows form
(or different window form, doesnt matter).
3. Now I have another copy (or clone) of the GroupBox with a Button
and a Texbox control inside it. They have different name (should be
groupBox2, button2 and textBox2).
However I want to do this with code. I try this
----------------------------------------------------------------------
GroupBox groupNewBox = groupBox1;
----------------------------------------------------------------------
But this is groupNewBox is referencing groupBox1.
I can do this,
----------------------------------------------------------------------
GroupBox groupNewBox = new GroupBox();
groupNewBox.Text = groupBox1.Text;
Foreach( Control ctrl in groupBox.Controls)
{
//take each control and manually recreate the
//control as child of groupNewBox
}
1. Put a GroupBox on a window form. Put a Button and TextBox inside the
GroupBox .
2. Select the group box, do copy and paste inside the same windows form
(or different window form, doesnt matter).
3. Now I have another copy (or clone) of the GroupBox with a Button
and a Texbox control inside it. They have different name (should be
groupBox2, button2 and textBox2).
However I want to do this with code. I try this
----------------------------------------------------------------------
GroupBox groupNewBox = groupBox1;
----------------------------------------------------------------------
But this is groupNewBox is referencing groupBox1.
I can do this,
----------------------------------------------------------------------
GroupBox groupNewBox = new GroupBox();
groupNewBox.Text = groupBox1.Text;
Foreach( Control ctrl in groupBox.Controls)
{
//take each control and manually recreate the
//control as child of groupNewBox
}