简体   繁体   中英

C# combobox select new item

Is it possible to set the selected item of a combobox to be an object that is not in its dropdown list?

If yes, then what must one do?

Use the Text property:

comboBox.Text = "I'm not in the list!";

If you want to add the item to the list, use the Items collection:

comboBox.Items.Add("I was added to the list!");

Is there a reason you cannot add it to the list after the object was generated? Is the object generated asynchronously?

myComboBox.Items.Add(newItem);

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