简体   繁体   中英

c#: Populate combobox at design time

我已经知道如何使用c#代码填充组合框,但有没有办法在设计时使用设计器/属性填充组合框?

Go to the Properties explorer of combo box or Press F4 find the Items property. Refer to the image below. 组合框属性

Hope it helps.

See Dans Answer :

var items = new BindingList<KeyValuePair<string, string>>();

items.Add(new KeyValuePair<string, string>("Mpost", "Posted"));
items.Add(new KeyValuePair<string, string>("Call", "Calling"));
items.Add(new KeyValuePair<string, string>("RScan", "Re-Scan"));

myComboBox.DataSource = items;
myComboBox.ValueMember = "Key";
myComboBox.DisplayMember = "Value";

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM