With this code I can create labels at runtime:
ArrayList CustomLabel = new ArrayList();
foreach (string ValutaCustomScelta in Properties.Settings.Default.ValuteCustom)
{
CustomLabel.Add(new Label());
(CustomLabel[CustomLabel.Count - 1] as Label).Location = new System.Drawing.Point(317, 119 + CustomLabel.Count*26);
(CustomLabel[CustomLabel.Count - 1] as Label).Parent = tabPage2;
(CustomLabel[CustomLabel.Count - 1] as Label).Name = "label" + ValutaCustomScelta;
(CustomLabel[CustomLabel.Count - 1] as Label).Text = ValutaCustomScelta;
(CustomLabel[CustomLabel.Count - 1] as Label).Size = new System.Drawing.Size(77, 21);
Controls.Add(CustomLabel[CustomLabel.Count - 1] as Control);
}
I need create labels on tabPage2, but this row not work:
(CustomLabel[CustomLabel.Count - 1] as Label).Parent = tabPage2;
Which is the correct instruction to create label on tabPage2 at runtime? (Im using visual studio 2010, windows form)