hel*_*boy 5 .net compact-framework winforms
已分配Combobox数据源
cmbCombobox.DataSource = myCollection
Run Code Online (Sandbox Code Playgroud)
其中myCollection的类型为MyCollection:List
如何清除组合框中的项目?
Ala*_*lan 24
数据绑定控件时,它将与该集合同步.为了清除ComboBox中的项目,将其DataSource设置为null.
cmbComboBox.DataSource = null;
Run Code Online (Sandbox Code Playgroud)
如果您的组合框不是数据绑定(没有数据源),那么您可以这样做
cmbComboBox.Items.Clear();
Run Code Online (Sandbox Code Playgroud)