两个Listbox,都可以进行复选.从listbox1选择N条到listbox2显示,并删除listbox1选中的数据 for i:=0 to 30 do
     begin
        if listbox1.Selected[i] then
             listbox2.Items.Add(listbox1.Items[i]);
        end;
复制可以,但删除有问题,下面是删除代码,只能删一条,不能删多条
 for i:=0 to listbox1.Count-1 do
     begin
       if listbox1.Selected[i] then
        listbox1.Items.Delete(listbox1.ItemIndex);
     end;

解决方案 »

  1.   

    删除代码改成:
    for i:=ListBox1.Count-1 downto 0 do
         begin
           if listbox1.Selected[i] then
            listbox1.Items.Delete(listbox1.ItemIndex);
         end;
      

  2.   

    错了。
    for i:=ListBox1.Count-1 downto 0 do
         begin
           if listbox1.Selected[i] then
            listbox1.Items.Delete(i);
         end;
      

  3.   

    或者:
        ListBox1.DeleteSelected;
      

  4.   

    如果listbox1.Items.Delete(i);后,ListBox1.Count的值就发生了变化,就报错了
      

  5.   

    如果listbox1.Items.Delete(i);后,ListBox1.Count的值就发生了变化,就报错了////////////////////
    所以要有Count 向 0 循环,这样就不会出问题了。最简洁的是ListBox1.DeleteSelected;