/// <summary>
/// C#中获取CheckListBox选中项的值。
/// </summary>
/// <param name="clb">要被获取选中项的CheckListBox类型的对象。</param>
/// <returns>返回一个ArrayList类型的对象。</returns>
private ArrayList GetCheckedItemsText(CheckedListBox clb)
{
ArrayList result = new ArrayList();
IEnumerator myEnumerator = clb.CheckedIndices.GetEnumerator();
int index;
while (myEnumerator.MoveNext())
{
index = (int)myEnumerator.Current;
clb.SelectedItem = clb.Items[index];
result.Add(clb.Text);
}
return result;
}
本文介绍了一种在C#中从CheckListBox控件获取所有选中项的方法,通过使用枚举器遍历选中项的索引并将其添加到ArrayList中,实现了对CheckListBox选中项的有效读取。
1171

被折叠的 条评论
为什么被折叠?



