procedure TmainFrm.Button1Click(Sender: TObject);
begin
if listbox1.Items.Count>0 then
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
后,出现list index out of bound(-1)的错误,怎么消除这个错误!先用选中一项再按钮就没事,谢谢!
begin
if listbox1.Items.Count>0 then
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
后,出现list index out of bound(-1)的错误,怎么消除这个错误!先用选中一项再按钮就没事,谢谢!
if listbox1.Items.Count>0 then
换成
if (listbox1.Items.Count>0) and (listbox1.itemindex>=0) then
试试看
ListBox1.Items.Delete(ListBox1.ItemIndex);
大家再帮我看看吧!
begin
if listbox1.ItemIndex<-1 then
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;如果还是有错就是其他问题了
begin
if listbox1.ItemIndex>=0 then
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;如果还是有错就是其他问题了