comboBox下拉列表
我想实现这样的功能:
当dropdown是comboBox的下拉列表这样显示:
1 文具类
2 食品类
3 衣类
而当选中其中一个时我让它在comboBox中的值为:
1
2
3
下拉显示的数据通过修改 DisplayMember属性就可以了,
而comboBox中的值 通过那个属性设置呢?
[解决办法]
你定制 ComboBox 的 Format 事件了?
[解决办法]
为什么不要食品类呢
可以看明白啊,重新绑定吧,绑定没有后面的那个汉字,和刚才选中的对应起来
[解决办法]
嗷明白你的意思了
你定制 一下, 执行一个多字段绑定就可以了
微软的例子
this.culturesCB.ValueMember = "LCID"; this.culturesCB.DataSource = CultureInfo.GetCultures(CultureTypes.FrameworkCultures); /* Set the currently selected item in the ComboBox */ this.culturesCB.SelectedValue = CultureInfo.CurrentCulture.LCID; /* Concatenate the IetfLanguageTag and DisplayName properties */ this.culturesCB.Format += delegate(object cb, ListControlConvertEventArgs args) { CultureInfo ci = (args.ListItem as CultureInfo); if (null != ci) { args.Value = string.Format("{0}: {1}", ci.IetfLanguageTag, ci.DisplayName); } };
[解决办法]
cboDis.DisplayMember = Dis.Tables[0].Columns["DisN"].ColumnName;
cboDis.ValueMember = Dis.Tables[0].Columns["DisNO"].ColumnName;
取value值
[解决办法]
好像和我 问的两个问题 一样嘛!
http://topic.csdn.net/u/20080731/18/e0a2816c-0bad-4ab6-b420-086ddaba0a22.html
http://topic.csdn.net/u/20080801/10/a608e0b4-6126-49d6-8274-020123ae1a8f.html