我有 c# Winform
Listbox
已经绑定(bind)到 数据源
。
var custList=Cusomer.CustomerList();
lstbox.DataSource=custList;
`enter code here`
lstbox.DisplayMember="CustName";
lstbox.ValueMemebr="CustId";
现在我想将一个名为“All”的文本添加到同一个列表框
,以便它应该显示为第一个listitem
。此外,通过 binding
添加的列表项也应该出现在那里。我的想法是,当用户选择“全部”选项时,必须自动选择所有列表项。
知道如何添加新文本值吗?
谢谢。
最佳答案
使用 ListBox.Items.Insert
并指定 0
作为索引。
ListBox1.Items.Insert(0, "All");
关于c# - 如何将文本项添加到已与数据源绑定(bind)的 winform 列表框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17212694/