是否可以将字典值绑定到Windows Combobox
?
我只能为WPF应用程序找到好的解决方案
Dictionary<object,object>ProductInfo = new Dictionary<object, object>();
foreach (var data in p)
{
ProductInfo.Add(data.PenType, data.PenColor);
Console.WriteLine("{0} {1}", data.PenType,data.PenColor);
}
答案 0 :(得分:1)
是的,您可以使用BindingSource Property
combobox1.DataSource = new BindingSource(ProductInfo,null);
//ProductInfo is your dictionary
combobox1.ValueMember = "Key";
combobox1.DisplayMember= "Value";