public class ListItem
{
private string textField;
public string TextField
{
get { return textField; }
set { textField = value; }
}
private string valueField;
public string ValueField
{
get { return valueField; }
set { valueField = value; }
}
}
//下面绑定
System.Collections.ArrayList list = new System.Collections.ArrayList();
for (int i = 0; i < 10; i++)
{
MyListItem listItem = new MyListItem();
listItem.TextField = "Text " + i;
listItem.ValueField = i.ToString();
list.Add(listItem);
}
combobox.DataSource = list;
combobox.DisplayMember = "TextField ";
combobox.ValueMember = "ValueField ";