日期:2014-05-18  浏览次数:20711 次

listBox的删除?
为什么
listBox1.BeginUpdate();
listBox1.Items.Remove(2);
listBox1.Items.Insert(1, "r");
listBox1.EndUpdate();
为什么这个代码不能删除。是不是这句listBox1.Items.Remove(2);删除一项写错了?

------解决方案--------------------
listBox1.Items.Remove(2);
这里面应该是个字符串,
listBox1.Items.Remove("2");
测试OK
------解决方案--------------------
如果你要删索引用listBox1.Items.RemoveAt(2);
如果你要删字符串用listBox1.Items.Remove( "2 ");