I have a windows form that has 4 comboboxes inside. These 4 boxes are linked, in that when the first box receives user selected data, the second box populates. When the second box receives user selected data, the third box populates. At least that is how I want this to happen. Instead, when the form loads, the first box populates, and so the SelectedIndexChanged event is thrown. This triggers the second combobox, and subsequently the third. Is there a way to keep this from happening? Of course, the first combobox will be populated with the form_load, but to keep the others from populating?

Any ideas are appreciated! Thanks!

5 Years
Discussion Span
Last Post by Reverend Jim

Try to set Combobox SelectionIndex = -1 to make it not select any items on Form Load event.

Combobox1.SelectionIndex = -1

Or you could have a class level variable like

Private Initializing As Boolean = True

and set it to False at the end of the initialization. Then in your SelectedIndexChanged events you could do

If Initializing Then Exit Sub

That would prevent those events from processing until the initialization is done.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.