ComboBox DisplatMember显示Code和Name的方法
private void ShopList(Dictionary<string, ShopInfo> shopLists, ComboBox comboBox, string shopCode)
{
if ((shopLists != null) && (shopLists.Count != 0))
{
var item = new ListItem("", "");
var listItem = new List<ListItem>();
listItem.Add(item);
foreach (ShopInfo info in shopLists.Values)
{
item = new ListItem(info.CODE.Trim(), "[" + info.CODE.Trim() + "] " + info.FULLNAME);
listItem.Add(item);
}
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Code";
comboBox.DataSource = listItem;
if (!string.IsNullOrEmpty(shopCode))
{
comboBox.SelectedValue = shopCode;
}
else
{
comboBox.SelectedIndex = 0;
}
}
}