comboxedit绑定数据源

使用 ComboBoxEdit 控件绑定key/value值:

因为 ComboBoxEdit 没有 DataSource 属性,所以不能直接绑定数据源,只能一项一项的添加。

先创建一个类

public class ListItem : Object

{ public string Text { get; set; }

public string Value { get; set; }

public ListItem(string text,string value)

{ this.Text = text; this.Value = value; }

public override string ToString()

{ return this.Text; }

}

然后绑定

public void BindSource(){

string text = string.Empty;

string value = string.Empty;

ListItem item = null;

for (int i = 0; i < 4; i++)

{

if (i==0)

{

 text = "请选择";

}

else
{
text = "选项" + i.ToString();
}
value = i.ToString();
item = new ListItem(text, value);
this.comboBoxEdit1.Properties.Items.Add(item);
} }

原文地址:https://www.cnblogs.com/yourSixUncle/p/9885323.html