user1161257
user1161257

Reputation: 45

c# duplicate panels dynamically

I need to dynamically duplicate a Panel with all the controls within it according to the checkboxes. (If check-box is checked another panel appears).

Finally, when I click Calculate it's doing the same pre-defined action for each panel that created.

Picture to understand:

enter image description here

Can someone tell me how to do that?

Upvotes: 3

Views: 3913

Answers (1)

nunespascal
nunespascal

Reputation: 17724

Put the controls you want into a UserControl.

When a checkbox is checked, created an instance of that control and add it.

MyPanel myPanel = new MyPanel();
myPanel.Location = new Point(25,25);
this.Controls.Add (myPanel);

Location is where you want it in your form.

Upvotes: 3

Related Questions