Combobox text when clearing items [closed]

自古美人都是妖i 提交于 2019-12-14 03:35:11

问题


I'm dealing with the fact that when I clear items in a combobox programmatically, the text do not change and keep the last selected item.

How can I do it?


回答1:


Try

comboBox.SelectedIndex = -1;

Or

comboBox.Items.Clear();
comboBox.ResetText();



回答2:


Another way for combo boxes:

Populate

comboBox1.DataSource = new string[] { "", "bruce", "clark", "tony" };

Clear

comboBox1.DataSource = null;


来源:https://stackoverflow.com/questions/37525422/combobox-text-when-clearing-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!