C# 向带有数据源的组合框中添加项目(“请选择”->)

C# 向带有数据源的组合框中添加项目(“请选择”->),c#,winforms,combobox,datasource,C#,Winforms,Combobox,Datasource,我有一个带有数据源的组合框,但我想添加一个项 我希望它看起来像这样 ----Please select one--- //the item I want to add Tokyo //the items that came from the database Osaka //the items that came from the database Boston

我有一个带有数据源的组合框,但我想添加一个项

我希望它看起来像这样

----Please select one---     //the item I want to add 
Tokyo                        //the items that came from the database
Osaka                        //the items that came from the database
Boston                       //the items that came from the database
Manila                       //the items that came from the database
我该如何补救

谢谢

在设置数据源之前,您需要将“请选择”添加到要绑定到的集合中,例如

Combobox1.DataSource = Yourdatasource; // this is your datasource
Combobox1.Items.Add("----Please select one---");
var countries = GetCountriesFromDatabase(); // Get countries from the database

countries.Insert(0, "----Please select one---"); // Insert your please select item

Combobox1.DataSource = countries; // Assign the datasource after inserting the item

您的组合框的确切数据源是什么?一个
数据表
?或者其他什么?数据源是一个存储过程。这不是实际的数据源,这里的数据源应该是一些.NET集合,列表,…,您的
存储过程仅通过ADO.NET调用以获取数据,那么我需要做什么?如何确定确切的数据源?您为
组合框.DataSource
分配了什么?我不认为这是正确的-如果您尝试这样做,会得到一个ArgumentException,并显示消息“设置DataSource属性时无法修改Items集合。”