Fred,
Have you used DataBinding with Display,Value pair to add items to the
ComboBox, in that case use SelectedValue property, otherwise use
SelectedIndex property to select a default value during load.
Hope it helps.
this.cboCollect.Items.Add("abc");
this.cboCollect.Items.Add("e");
this.cboCollect.Items.Add("g");
this.cboCollect.Items.Add("h");
cboCollect.SelectedIndex = 3;
Thanks,
Vijai
"Fred" <fr**@email.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
Hi,
I am having a problem setting a combobox value in code on form load using
comboBox.SelectedValue method. The code below when debugging show the
combobox equal to an undefined value. The value I am trying to set is
present the items collection. I also have tried using .SelectedItem
method and I get an object reference error. Any ideas?
comboBox.SelectedValue = comboBoxValue;
Thanks