silly problem with combobox SelectedIndex and selectedValue in c# windows application
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:
Long time no see front end applications, but I would say that you need to select the item on the Combo DataBinding event.
BR
精彩评论