c# duplicate panels dynamically

c#, duplicates, dynamic, panel

Solution

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.

Problem

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: Can someone tell me how to do that?

Original source