ComboBox添加Item

自定义一个ListItem类

ListItem
public class ListItem
{
private string _key;

public string Key
{
get { return _key; }
set { _key = value; }
}

private string _value;

public string Value
{
get { return this._value; }
set { this._value = value; }
}

public ListItem(string key, string value)
{
_key
= key;
_value
= value;
}

public override string ToString()
{
return this._value;
}
}

取值

取值
string key = ((ListItem)comboBox1.SelectedItem).Key;
string value = ((ListItem)comboBox1.SelectedItem).Value;
string value = ((ListItem)comboBox1.SelectedItem).ToString();
原文地址:https://www.cnblogs.com/Robbery/p/2163576.html