我正在关注我在网上看到的检查项目的示例 但在示例中,它只检索一个值
int len = listview.Count;
SparseBooleanArray checkedItems = listview.CheckedItemPositions;
for (int i = 0; i < len; i++)
if (checkedItems.Get(i))
{
string item = list[i];
/* do whatever you want with the checked item */
txt.Text = item;
}
那么我如何检索所有已检查的项目值?
答案 0 :(得分:0)
您需要创建某种数据结构
List<string> checkedItems = new List<string>();
int len = listview.Count;
SparseBooleanArray checkedItems =
listview.CheckedItemPositions;
for (int i = 0; i < len; i++)
if (checkedItems.Get(i))
{
checkedItems.Add(list[i]);
}