[英]Add an item (“---Please select---”) to a combo box with a data source
我有一個帶有數據源的組合框,但我想添加一個項目。
我希望它看起來像這樣。
----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
我該如何補救?
謝謝
您需要在設置數據源之前將“請選擇”添加到要綁定的集合中,例如...
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---");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.