M
Mark Rae
Hi,
In Windows (not Web) forms, is there a better way to refer to controls on
another form than the following:
ComboBox cmbMyCombo = (ComboBox)this.Owner.Controls[14];
cmbMyCombo.Items.Add(txtMyTextBox.Text);
In the above example, a "main" form opens a dialog form with a textbox on
it. The user enters some text in the textbox and then clicks a button which
adds the contents of the textbox to the combo box on the main form.
This works, but it is annoying not to be able to reference the combo box by
its name, or am I missing something here?
Any assistance gratefully received.
Best regards,
Mark Rae
In Windows (not Web) forms, is there a better way to refer to controls on
another form than the following:
ComboBox cmbMyCombo = (ComboBox)this.Owner.Controls[14];
cmbMyCombo.Items.Add(txtMyTextBox.Text);
In the above example, a "main" form opens a dialog form with a textbox on
it. The user enters some text in the textbox and then clicks a button which
adds the contents of the textbox to the combo box on the main form.
This works, but it is annoying not to be able to reference the combo box by
its name, or am I missing something here?
Any assistance gratefully received.
Best regards,
Mark Rae