【发布时间】:2014-04-14 13:32:55
【问题描述】:
我想将选中列表框和组合框的所有选定项添加到列表中,并在 c# 中的 for each 循环中使用该列表
我试过了
List<String> list=new List<String>();
if (rbtnMultipleScenario.Checked == true)
{
foreach ( CheckedListBox str in clbScenario.SelectedItems)
{
lstitems.Add(str);
}
}
通过使用字符串,我无法添加 Checkedlistbox 的所有选定项。
我必须使用哪种类型的列表?
【问题讨论】:
-
因为没有以
CheckedListBox为参数的List<T>.Add方法的重载。您为什么不尝试使用.Text或.ValueMember(存在哪一个)属性呢? -
实际上,借助“T”参数,您可以毫无问题地使用 List
。
标签: c# list combobox checkedlistbox