Click to See Complete Forum and Search --> : Make copy of label


elvinny
February 19th, 2009, 11:37 AM
Hi


I have 3 designed labels on forms with different colors and shapes.

I would like to know if in a file .cs make several copies of 3 pre designed labels on Forms. My purpose is to define and make visible only the necessary labels.

Example:

pseudo - code

pre designed label, label 2 and label 3

make n copies of these 3 labels

change location of each created labels

end of pseudo - code

Thanks

Talikag
February 19th, 2009, 11:43 AM
Here's an example how to create N labels on runtime:

const int N = 5;
Label[] labelA = new Label[N];
...
for(int i=0;i<N;i++)
{
labelA[i] = new Label();
labelA[i].Name = "LabelA" + i;
labelA[i].Size = label1.Size;
labelA[i].Location = new Location(WHATEVER...);
labelA[i].Color = label1.Color;
...
etc.

this.Controls.Add(labelA[i]);
}