Quote Originally Posted by larrycav View Post
To me, selecting the combobox is the only logical answer. You click it and it should present the desired data.
The event for what you are describing is Enter (or possibly DropDown) not SelectedIndexChanged. The Enter event happens when a control gains focus such as when the user clicks the ComboBox. SelectedIndexChanged event occurs when the user selects one of the items in the ComboBox. But you want all of the items already in the ComboBox before the user makes a selection (otherwise they may complain that the new item isn't listed; they'd have to select an item to get all of the items refreshed and then make their actual selection a second time after the ComboBox has refreshed).

I have created this small program to show the difference. It has a Button (named btnTest1) and a ComboBox (named cboTest) and has a List(Of String) that the ComboBox's DataSource is connected to:
VB.Net Code:
  1. Public Class Start
  2.     Public lstItems As New List(Of String)
  3.  
  4.     Private Sub btnTest1_Click(sender As System.Object, e As System.EventArgs) Handles btnTest1.Click
  5.         With Me.lstItems
  6.             .Add("A")
  7.             .Add("B")
  8.             .Add("C")
  9.         End With
  10.     End Sub
  11.  
  12.     Private Sub cboTest1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cboTest1.SelectedIndexChanged
  13.         Me.cboTest1.DataSource = Nothing
  14.         Me.cboTest1.DataSource = Me.lstItems
  15.     End Sub
  16.  
  17.     'Private Sub cboTest1_Enter(sender As Object, e As System.EventArgs) Handles cboTest1.Enter
  18.     '    Me.cboTest1.DataSource = Nothing
  19.     '    Me.cboTest1.DataSource = Me.lstItems
  20.     'End Sub
  21.  
  22.     Private Sub Start_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  23.         Me.lstItems.Add("Hello")
  24.         Me.cboTest1.DataSource = Me.lstItems
  25.     End Sub
  26. End Class
When the program runs, the ComboBox will initially just contain the word "Hello". When the button is clicked, the letters "A", "B", and "C" get added to the List. Then one of the ComboBox's events will trigger the List to be reset as its DataSource. Currently I have the SelectedIndexChanged handling the DataSource reset, but to see how the Enter event works, just comment out the SelectedIndexChanged handler and uncomment the Enter handler. Then do these steps to see the difference:
  • Run the program and drop-down the ComboBox to see its initial items (eg the word "Hello")
  • Click on the Button to add some more items to the List
  • Drop-down the ComboBox again. If the Enter event handler is enabled, then you'll see all of the items listed (eg "Hello", "A", "B", and "C"); at this point you can quit. If the SelectedIndexChanged handler is enabled, then it will look like nothing happened and only the word "Hello" will be listed; you'll need to continue with the remaining steps to see the new items in the List for the ComboBox.
  • While the ComboBox is in its drop-down state, click on the word "Hello". The ComboBox should close at this point (showing only the editable portion with the drop-down list hidden).
  • Drop-down the ComboBox again to see that the DataSource was reset when you selected the word "Hello" in the previous step.