开发者

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:

silly problem with combobox SelectedIndex and selectedValue in c# windows application

Image 2:

silly problem with combobox SelectedIndex and selectedValue in c# windows application

Image 3:

silly problem with combobox SelectedIndex and selectedValue in c# windows application

Image 4:

silly problem with combobox SelectedIndex and selectedValue in c# windows application


Long time no see front end applications, but I would say that you need to select the item on the Combo DataBinding event.

BR

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜