添加带有数据源的项目组合框

add item combobox with datasource

我有一个方法 (LoadCustomers()) returns 元素字典如下:

Dictionary<int, string>()

我像这样将它连接到组合框的数据源:

             Myclass m = new Myclass();
             combo1.DataSource = new BindingSource(m.LoadCustomers(), null);
             combo1.DisplayMember = "Value";
             combo1.ValueMember = "Key";

现在我想在组合框列表前面放置一个项目,例如:

             <select one customer>

如何在 winforms 上使用 c# 执行此操作?

非常感谢

将此选项添加到客户词典

const int EMPTYCUSTOMERKEY = -1;  //be sure Customers will not contain this value
const string EMPTYCUSTOMERVALUE = "<select one customer>";

Myclass m = new Myclass();
Dictionary<int, string> customerSource = m.LoadCustomers();

customerSource.Add(EMPTYCUSTOMERKEY, EMPTYCUSTOMERVALUE);

combo1.DataSource = new BindingSource(customerSource, null);
combo1.DisplayMember = "Value";
combo1.ValueMember = "Key";