小的对ListBox不是很了解,在做程序是遇到了些难题:
1,如何通过按钮实现对ListBox的内容的全选?(假如:ListBox中的内容是标题,一行一行的)
2,在ListBox1中显示的内容选入ListBox2后,如何将该内容在ListBox1中去掉。(假如:ListBox中的内容是标题,一行一行的)
请教各位大虾!

解决方案 »

  1.   

    1)listbox mutil...属性=true,按住shift选取
    2)listbox1.items.delete(listbox1.itemindex);...是不是?我这里没有delphi,不能帮你写了
      

  2.   

    (1)listbox1.MultiSelect := true;
       listbox1.SelectAll;
    (2)listbox2.Items.AddStrings(listbox1.Items);
       listbox1.Items.Clear;
      

  3.   

    哦,看错了,第二个问题是:
      listbox2.Items.Add(listbox1.Items.Strings[listbox1.ItemIndex]);
      listbox1.DeleteSelected;
      

  4.   

    To:coeltdit(睫毛上的冰),rouqing(*冰雨&双子座奇缘*)
       谢谢两位大虾。!!!
      

  5.   

    To:coeltdit(睫毛上的冰)
      对于第一个问题,如果我想再进一步来实现,如:我全选后,再往ListBox2中添加的话如何实现:
    我的实现是这样的:
    var
      i:Integer;
    For i:=0 to ListBox1.Items.Count-1 do 
    begin
      if ListBox1.Selected[i] then
      begin
        ListBox2.Items.Add(ListBox1.Items.Strings[ListBox1.ItemIndex]);
        ListBox1.DeleteSelected;
      end;
    end;
    不过,调试的时候还是有问题:Project Project1.exe raised exception class EListError with message"List index out of bounds(112)",Process stopped.
    请教:是不是我的For语句用得不对,我觉得提示得意思应该是越出他得查找范围了。应该怎写才对?
      

  6.   

    var
      i:Integer;
    begin
      For i:=0 to ListBox1.Items.Count-1 do
        ListBox2.Items.Add(ListBox1.Items.Strings[i]);
        listbox1.Clear;
    end;
      

  7.   

    var
      i:Integer;
    begin
      For i:=0 to ListBox1.Items.Count-1 do
        ListBox2.Items.Add(ListBox1.Items.Strings[i]);
        listbox1.SelectAll;
        listbox1.DeleteSelected;
    end;
      

  8.   

    listbox2.Items.Assign(listbox1.Items);
       listbox1.Clear;
    ------------------------------------------------------
       这样最好吧!
      

  9.   

    For i:=0 to ListBox1.Items.count-1 do
    begin
      if ListBox1.Selected[i] then
      begin
        ListBox2.Items.Add(ListBox1.Items.Strings[i]);
      end;
    end;
      ListBox1.DeleteSelected;
      

  10.   

    (1)listbox1.MultiSelect := true;
       listbox1.SelectAll;
    (2)
      listbox2.Items.Add(listbox1.Items.Strings[listbox1.ItemIndex]);
      listbox1.DeleteSelected;