I'm developing in VB.NET with Visual Studio 2005.
I have a ComboBox (myCombo) on a form that gets populated within the Load method.
I also have handled myCombo.SelectedIndexChanged to change a label on the form.
Edit: The way I added the event handler was by double-clicking on the combo box on the designer. Skeleton code then came up in the code view.
It looks like what's happening is when the form loads, SelectedIndexChanged gets fired each time an item is added to myCombo.
This isn't what I want, but I'm thinking there's another event handler that only gets called when the user changes the selection.
Here's some code for what I have:
Private Sub myDlg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' this is all I do with myCombo in this sub
list = GetListOfItemsToAdd()
myCombo.DataSource = list
myCombo.DisplayMember = "DisplayMember"
myCombo.ValueMember = "ValueMember"
End Sub
Could someone point me in the right direction?
Thanks as always.
Update: The solution I used was to remove the Handles clause after the event generator, and add this before the "End Sub" above:
AddHandler myCombo.SelectedIndexChanged, AddressOf myCombo_SelectedIndexChanged
Thanks everyone!