public class ComboxItem
{
public string Text = "";
public string Value = "";
public ComboxItem()
{
}
public ComboxItem(string _Text, string _Value)
{
Text = _Text;
Value = _Value;
}
public override string ToString()
{
return Text;
}
}
二.给控件绑定具有text和value的值
ComboxItem item = new ComboxItem();
item.Text = "执收单位";
item.Value = "BAS_ChargeAgency";
cboStats.Items.Add(item);
cboStats.DisplayMember = "Text";
cboStats.DisplayMember = "Value";
cboStats.SelectedIndex = 0;
三.当选择索引改变时如果获得所选项的value的值
if (cboStats.SelectedItem == null)
return;
string itemvalue =((ComboxItem) cboStats.SelectedItem).Value;
TreeViewLoad((object)itemvalue);