首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

listBox的删除?解决办法

2012-01-14 
listBox的删除?为什么listBox1.BeginUpdate()listBox1.Items.Remove(2)listBox1.Items.Insert(1, r)l

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 "); 

热点排行