I have a combo box with data source but I want to add an item.
I want it to look like this.
----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
How do I remedy this?
Thanks
You need to add the "please select" to the collection that you are binding to before setting the datasource, for example...
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
Combobox1.DataSource = Yourdatasource; // this is your datasource
Combobox1.Items.Add("----Please select one---");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.