简体   繁体   English

选择数据源后将项目添加到组合框

[英]Add item to combobox after data source selected

I want to add an item to the combobox after binding it. 我想在绑定项目后将其添加到组合框中。 for example: 例如:

DataSet csuname = new DataSet();
csu.Fill(csuname);
comboBox1.DataSource = csuname.Tables[0];
comboBox1.DisplayMember = "empfname";
comboBox1.Items.Add("all");

but it gets error like 但是它会出现错误

Items collection cannot be modified when the DataSource property is set. 设置DataSource属性后,将无法修改项目集合。

what is the best way to do this? 做这个的最好方式是什么?

最好的方法是将该项直接添加到您的数据源csunam.Tables[0] ,我还要假定它必须是一个可观察的集合才能起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM