0

I need to add some usercontrol in a form. But I should create it with a parametric name ex. control1, control2 ect...

So to add the control I use this code:

//MachineArea Is my usercontrol that i Need ti show in UI

MachineArea machineArea1  = new MachineArea();
machineArea1.LoadMachine("sample 1", "");
machineArea1.Location = new System.Drawing.Point(122, 280);
machineArea1.Name = "machineArea1";
machineArea1.Size = new System.Drawing.Size(281, 127);

this.Controls.Add(machineArea1);

I would like to enter this code inside a for cycle and change the last char of control name with index of cycle, like below.

for (int i = 0; i < Nrmachine; i++)            
{
MachineArea machineArea + i = new MachineArea();

It's possible?

Thank's

0 Answers0