组合框索引 [英] ComboBox Index
本文介绍了组合框索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在工作中发现了一个有趣的问题.我在我的Form
中为两个ComboBox
设置了不同的SelectedIndex
值.但是,两个ComboBox
的值都与结尾处设置的值相同.
为什么会这样呢?
我的代码是这样的:
Hi
I found an interesting issue during my work. I am setting different SelectedIndex
values to two ComboBox
es in my Form
. But both the ComboBox
es have the same value which is set at the end.
Why this might be so?
My code is like this:
var list = new List<system.collections.dictionaryentry>();
list.Add(new System.Collections.DictionaryEntry("one", 1));
list.Add(new System.Collections.DictionaryEntry("two", 2));
comboBox1.DataSource = list;
comboBox1.DisplayMember = "Key";
comboBox1.ValueMember = "Value";
comboBox1.SelectedIndex = 0;
comboBox2.DataSource = list;
comboBox2.DisplayMember = "Key";
comboBox2.ValueMember = "Value";
comboBox2.SelectedIndex = 1;
在此函数的结尾,comboBox1
和comboBox2
的SelectedIndex
值都为1,而不是分别为0和1.
任何的想法? :)
问候
Fadi
Here at the end of the function, both comboBox1
and comboBox2
have SelectedIndex
value as 1 instead of being 0 and 1 respectively.
Any idea? :)
regards
Fadi
推荐答案
ComboBox2.SelectedIndexChanged事件中有东西吗?
Is there anything in ComboBox2.SelectedIndexChanged Event?
这篇关于组合框索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文