Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 902
user1161257 Avatar asked Dec 29 '25 21:12

user1161257


1 Answers

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.

like image 98
nunespascal Avatar answered Dec 31 '25 09:12

nunespascal