开发者

C# combobox select new item

开发者 https://www.devze.com 2022-12-25 17:34 出处:网络
Is it possible to set the selec开发者_如何学Goted item of a combobox to be an object that is not in its dropdown list?

Is it possible to set the selec开发者_如何学Goted 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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号