清除组合框数据源项 [英] Clear combobox datasource items

查看:96
本文介绍了清除组合框数据源项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

组合框数据源已分配给

cmbCombobox.DataSource = myCollection

其中myCollection类型为MyCollection:列表

where myCollection has type MyCollection: List

如何清除组合框中的项目?

How can I clear items in combobox?

推荐答案

数据绑定控件时,它将与该集合同步。为了清除ComboBox中的项目,请将其DataSource设置为null。

When you data bind a control, it will synchronize with that collection. In order to clear the items in your ComboBox set it's DataSource to null.

cmbComboBox.DataSource = null;

如果您的组合框是不是数据绑定的(没有DataSource),则可以

If your combobox is not databound (no DataSource) then you can do

cmbComboBox.Items.Clear();

这篇关于清除组合框数据源项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆