Ok, I'm loading some values into a combobox (and other controls) and I have a SelectedIndexChanged event for this combobox. Now, in the event I need to evaluate either the Value or the Text.
Now what happens is that the SelectedIndexChanged event fires multiple times while the form loads and the data is fed into the combobox from the datasource.
Before there are any items fed into the combobox, the Text and value are Null, which causes errors on trying to evaluate.
I have two solutions to this problem:
1. Try statements around anything reading from the combobox.
2. Set a variable like isLoaded which is set to false and made true after the formLoad event is finished or the database is finished loading.
The first solution looks like a huge waste. I'm not sure how much wasted resources go into a Try statement, but doing it with every control seems kind of silly. Maybe thats the best way to go.
The second solution looks really silly. Performance wise, checking for a true value shouldn't be hard, but it seems rather messy to go throwing around this variable and making all these checks (there are other controls with the same problem)
As well, I get this problem with the RecordChanged event for the BindingSources as well. Again a Try statement might be the correct way to go on this.
Are there any other solutions to this problem?
Now what happens is that the SelectedIndexChanged event fires multiple times while the form loads and the data is fed into the combobox from the datasource.
Before there are any items fed into the combobox, the Text and value are Null, which causes errors on trying to evaluate.
I have two solutions to this problem:
1. Try statements around anything reading from the combobox.
2. Set a variable like isLoaded which is set to false and made true after the formLoad event is finished or the database is finished loading.
The first solution looks like a huge waste. I'm not sure how much wasted resources go into a Try statement, but doing it with every control seems kind of silly. Maybe thats the best way to go.
The second solution looks really silly. Performance wise, checking for a true value shouldn't be hard, but it seems rather messy to go throwing around this variable and making all these checks (there are other controls with the same problem)
As well, I get this problem with the RecordChanged event for the BindingSources as well. Again a Try statement might be the correct way to go on this.
Are there any other solutions to this problem?