Reputation: 13447
I Have a silly problem with combobox selectedindex.I have a usercontrol(UC) and I place a combobox on it. in UC load event I bind combo to a datatable(or even List) that has 10 rows and then I want to select socond Item but I get an out of range exception.
the fun is when I comment selecting second row and run application combo has 10 Items.
if I use any thing instead of BindingSource I have prolem.Ho I can Solve That? thanks
Edit 1) Here is the code:
comboBox1.DataSource = dsBase.Tables["MyDt"];
comboBox1.DisplayMember = "Desc";
comboBox1.ValueMember = "ID";
comboBox1.SelectedIndex = 1;
Edit 1) Can any body Explain this images?
Image 1:
Image 2:
Image 3:
Image 4:
Upvotes: 1
Views: 975
Reputation: 351
Long time no see front end applications, but I would say that you need to select the item on the Combo DataBinding event.
BR
Upvotes: 1