Hi friends,
I am trying to add multiple LABEL controls in my program using a GROUP.I am using the folllowing code
Label newlabel = new Label();
void functionname(..... , ....)
{
int i = 0;
foreach (string s1 in s2)
{
newlabel = new Label();
newlabel.AutoSize = true;
newlabel.Text = s1;
newlabel.Location = new System.Drawing.Point(50, 20+30*i);
newlabel.Name = s1;
newlabel.Size=new System.Drawing.Size(60,25);
newlabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
groupBox1.Controls.Add(newlabel);
i++;
}
}
where s2 is an array consisting of various names which are to be applied to the labels.
I want to associate a click event which will show the name of the label in Messagebox when clicked.
Please help!