I have created a form in which i have placed 40 combo boxes and 40 labels. Now i want to add text to the labels using a for loop.. the text for the labels wil be the items selected in the combox..
for example...
label1.text=combobox1.selecteditem.tostring();
label2.text=combobox2.selecteditem.tostring();
label3.text=combobox3.selecteditem.tostring();
label4.text=combobox4.selecteditem.tostring(); and so on..
this i want to do using for loop...
plzzzzz help me...
thanks in advance...
Santhosh NPosted Dec 31, 2009, 6:11 AM
for (int i = 1; i <= 40; i++)
{
this.Controls["label" + i].Text = this.Controls["combobox" + i].SelectedItem.ToString();
}