Hi I am adding comboboxes dynamically in a panel in windows form application. At run time, when I select any one of the comboboxes, all the comboboxes changes. i.e they dont retain individual selected item values.
here is my code.
for(int i=0;i<20;i++)
{ Label l = new Label();
l.Text = ColumnNames[i];
l.Width = 250;
cboColumnNames[i] = new ComboBox();
cboColumnNames[i].Width = 250;
cboColumnNames[i].DataSource = colname;
cboColumnNames[i].Name ="Combo"+ i.ToString();
l.Location = new Point(55, (i * 30) + 45);
panel1.Controls.Add(l);
cboColumnNames[i].Location = new Point(750, (i * 30) + 45);
panel1.Controls.Add(cboColumnNames[i]);
cboColumnNames[i].SelectedIndexChanged += new EventHandler(ComboBoxSelectedIndexChanged);
}
How can I solve this issue?