for (int i = 0; i < ListBox1.Items.Count; i++) { if (Convert.ToString(ListBox1.Items[i]).IndexOf("无效") != -1) { ListBox1.Items.RemoveAt(i); } } 上面的代码已经试过了,请不要再贴出来
[解决办法]
[解决办法] for (int i = 0; i < ListBox1.Items.Count; i++) 改为 for (int i = ListBox1.Items.Count-1; i >=0; i--) [解决办法]