I make a code that aims to make a combobox with an associated label. How can I get the label to show the value found in the combo box.
There is provided a combobox and a label each time you press a button, so there will be x-number of comboboxes and labels.
ArrayList cboRunList = new ArrayList();
ArrayList labRunList = new ArrayList();
private void button1_Click(object sender, EventArgs e)
{
// Tilføjer ComboBoxe
ComboBox cboRun = new ComboBox();
string[] s = { "", "a", "b", "c", "d", "1", "2", "3", "4" };
cboRun.DataSource = s;
cboRun.Location = new System.Drawing.Point(10, 10 + (20 * c));
cboRun.Size = new System.Drawing.Size(200, 25);
cboRunList.Add(cboRun);
cboRun.Click += new EventHandler(cboRun_Click);
Controls.Add(cboRun);
// Tilføjer label
Label labRun = new Label();
labRun.Name = "LabDyn" + c;
labRun.Location = new System.Drawing.Point(270, 10 + (20 * c));
labRun.Size = new System.Drawing.Size(1000, 20);
labRunList.Add(labRun);
labRun.Text = "LabDyn" + c;
Controls.Add(labRun);
c = c + 1;