Combobox.SelectedIndexChanged

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use a AddHandler statement in the load event of a form to assoicate a
routine with a combobox. When I populate the form, I select the approiate
value from the combobox by using combobox.selectedvalue = value. The weird
thing is sometimes this causes the assoicated routine to be called and
sometimes it does not. The combobox below it that is completely identical
except for the name works every time. After the form is displayed, you can
select something from the combobox and the routine fires.

Does anybody know why this is happening or has anybody had anything similiar
to this happen to them?
 
I figured it out. I feel like an idiot! The reason the SelectedIndexChanged
event was not firing was because the SelectedIndex was not changing. I was
thinking that after populating the combobox that Nothing(-1) would be
selected, however, I forgot to set it to Nothing after populating it. So, of
course, the first item was automatically displayed/selected. So whenever I
tried to set the selectedvalue of the combobox to the value at index 0, in
code after populating it, the SelectedIndexChanged event would not fire
because it was already selected!
 
Back
Top