添加元素:comboboxedit.Properties.Items.Add();
修改内容 :comboboxEdit.Text = str;
读出选定的数据:string str = comboboxedit.Properties.Items[comboboxeditDept.SelectedIndex].ToString();
在一些情况需要Value 和 Name 进行绑定:
这时得创建一个类:
public class NameValueClass
{
public string name;
public string id;
public NameValueClass(string _name, string _id)
{
name = _name;
id = _id;
}
public override string ToString()
{
return this.name;
}
}然后绑定的时候:
comboboxedit.Properties.Items.Add(new NameValueClass(name, value));在选定列表某个值的时候就可以读出value了。
string code = ((NameValueClass)comboboxedit.Properties.Items[comboboxedit.SelectedIndex]).id;
本文介绍了如何使用ComboBoxEdit控件进行元素的添加、修改及读取操作,并演示了通过Value和Name绑定来获取选定项的值的具体实现方法。

1363

被折叠的 条评论
为什么被折叠?



