Board index » delphi » listbox clear?

listbox clear?

Hiya!

My very last question.. huh.. hehe..

How Do I clear all items listed in a listbox???

Cya
JB.

 

Re:listbox clear?


ListBox1.Items.Clear;

\Francois

Quote
SOrdid wrote:
> Hiya!

> My very last question.. huh.. hehe..

> How Do I clear all items listed in a listbox???

> Cya
> JB.

Re:listbox clear?


On Mon, 6 Jul 1998 17:05:36 +0200, "SOrdid" <ma...@post7.tele.dk>
wrote:

Quote
>How Do I clear all items listed in a listbox???

procedure TForm1.Button1Click(Sender: TObject);
var I: integer;
begin
  with ListBox1 do
    begin
      for I:=0 to Items.Count-1 do
        if Selected[I] then
          Selected[I]:=False
    end
end;

Re:listbox clear?


On Mon, 6 Jul 1998 17:05:36 +0200, "SOrdid" <ma...@post7.tele.dk>
wrote:

Quote
>Hiya!

>My very last question.. huh.. hehe..

If you ask always such questions... I belief not ;).

Quote

>How Do I clear all items listed in a listbox???

Listbox.Clear;

Bye, Michael

Re:listbox clear?


In article <35a11628.5760...@news.mia.bellsouth.net>, Mauri...@bellsouth.net

Quote
({*word*104}Cat) writes:
>procedure TForm1.Button1Click(Sender: TObject);
>var I: integer;
>begin
>  with ListBox1 do
>    begin
>      for I:=0 to Items.Count-1 do
>        if Selected[I] then
>          Selected[I]:=False
>    end
>end;

Did he mean clear in that respect ? If so another way is to :-

var
  MultiSel : boolean;
begin
  with ListBox1 do begin
    MultiSel := MultiSelect; {save the setting}
    MultiSelect := false;
    ItemIndex := -1;
    MultiSelect := MultiSel; {restore the setting}
  end;
end;

I don't know how the speed would compare with a big TListBox.

Alan Lloyd
alangll...@aol.com

Re:listbox clear?


On 06 Jul 1998 18:58:44 GMT, alangll...@aol.com (AlanGLLoyd) wrote:

Quote
>In article <35a11628.5760...@news.mia.bellsouth.net>, Mauri...@bellsouth.net
>({*word*104}Cat) writes:

>>procedure TForm1.Button1Click(Sender: TObject);
>>var I: integer;
>>begin
>>  with ListBox1 do
>>    begin
>>      for I:=0 to Items.Count-1 do
>>        if Selected[I] then
>>          Selected[I]:=False
>>    end
>>end;

>Did he mean clear in that respect ?

The gremlins in my news reader are acting up again. I could have sworn
it displayed the word "selected" instead of the word "listed" when I
had first read that message. <grin>

Re:listbox clear?


I got it working now dudes...

listbox1.clear

=)
Cya

Re:listbox clear?


SOrdid <ma...@post7.tele.dk> wrote in article
<6nqpb4$ff...@news1.tele.dk>...

Quote
> How Do I clear all items listed in a listbox???

ListBox1.Clear;

Other Threads