I've got a Form with a TabControl. On the second tab, I have a ListBox with the selection mode set to MultiSimple. When I load the form, the SelectedIndexChanged event of the Tab Control gets called before the Form Load does. I have no idea why that is. I load up my values from my DB in the Form Load event, but when I select the second tab, the values of that ListBox and what is supposed to be selected are lost. It goes back to selecting the first value, which it does by default. Again, I have no idea why. So to fix that, I ended up loading up the values of that ListBox from the DB on that SelectedIndexChanged event of the Tab Control. Which works fine (so everytime that specific tab is selected, it loads the correct values), but if someone changes the values and then goes to a different tab, once they go back to that tab, all of those values they just selected are gone. Of course, since my SelectedIndexChanged event was tripped again and it reloaded the values from the DB.
Is this a bug in the .NET Framework? Or am I doing something wrong? None of the other controls act this way. They all load up fine and don't change their values based on a Tab Control SelectedIndexChanged event. What am I doing wrong? Is there something I'm not setting somewhere?
If this truly is a bug, how can I get around this? I want the values to load up properly and also keep them selected in that Listbox if the tabs change. Any ideas?