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!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.