Select All in listview

how can i select all in listview with one click
eskAsked:
Who is Participating?
 
TheNeilConnect With a Mentor Commented:
Create your button then add something along the lines of the following:

VAR
  iCount : INTEGER;
begin
  FOR iCount := 0 TO (ListView1.Items.Count - 1)
  DO
    ListView1.Items[iCount].Selected := TRUE;
  ListView1.SetFocus;
end;

The Neil
0
 
TheNeilCommented:
Can you use the OnClick method and simply select everything in that?

The Neil
0
 
eskAuthor Commented:
i want to push a button, after that it selects all in this listview
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
eskAuthor Commented:
this is like multiselect , but i push a button and it select self all item
0
 
JaymolCommented:
Simple, but does what you asked for...

procedure TForm1.Button1Click(Sender: TObject);
var
  TmpI : Integer;
begin
  For TmpI:=0 to ListBox1.Items.Count-1 do
  ListBox1.Selected[TmpI]:=True;
end;

Hope this helps,

John.
0
 
JaymolCommented:
Doh!!!  Sorry.....You said listview, not listbox....

For TmpI:=0 to ListView1.Items.Count-1 do
ListView1.Items[TmpI].Selected:=True;
ListView1.SetFocus;

That'll do the trick!

John.
0
 
TheNeilCommented:
p.s. Make sure you set the MultiSelect property of your TListView to TRUE else it won't work

The Neil
0
 
JaymolCommented:
Ha!  (Forgot to mention MultiSelect though!)

John.
0
 
eskAuthor Commented:
work!!!
0
 
TheNeilCommented:
Thanks Esk,

Sorry John - looks like I won this time

The Neil
0
 
JaymolCommented:
This is pathetic.  I'm getting pissed off with you so called Experts.
0
 
JaymolCommented:
Who answered you first?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.