带Key,Value的ComboboxEdit
CmbInfo:
struct CmbInfo { public int _key; public string _text; public CmbInfo(int key, string text)
{
_key = key; _text = text;
}
public override string ToString()
{
return _text;
}
}
comboBoxEdit赋值:
ComboBoxItemCollection col1 = comboBoxEdit1.Properties.Items; col1.BeginUpdate(); col1.Add(new CmbInfo(1,"111")); col1.Add(new CmbInfo(2, "222"));
取值:
CmbInfo p=new CmbInfo (); p = (CmbInfo)(comboBoxEdit1.SelectedItem); string text = p._text; int value = p._key; MessageBox.Show(text + " " + value.ToString());

浙公网安备 33010602011771号