DELPHI l istbox.items.delete(i)
procedure TFMain.Button1Click(Sender: TObject);
var
i: integer;
begin
for i := ListBox1.Items.Count-1 downto 0 do
begin
if ListBox1.Selected[i] then //若为选中则
begin
ListBox1.Items.Delete(i);
end;
end;
end;
为什麽只能从最后一行开始删除?
参考答案:for i := ListBox1.Items.Count-1 downto 0 do
这个就是从后往前找的,如果想从前往后的话,可以改成
for i := 0 to ListBox1.Items.Count-1 do