winfromlistbox专题

C# winfromListBox 查找选中项是集合中的第几个

看到网上好多办法是调GetSelectedIndices方法或者是selected方法,我都试过了,不知道为什么都调不出来,没办法自己写了一个 for (int i = 0; i < ListBox.Items.Count; i++){bool item = ListBox.GetSelected(i);} 注意:如果循环过程中ListBox.Items.Count数字发生修改,判断可能出问题