Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select All in TList view 1

Status
Not open for further replies.

sggaunt

Programmer
Jul 4, 2001
8,620
GB
You can select everyting in a list view (multi-select is on)by looping though all the items and setting selected true for each, however the selection is not 'visible' after this process, if a sigle item has been pre-seletd then the whole list will show as selected.
does anyone know how to make the selected list visible programatically ?


Steve
Those who know me have no need of my name. SD
 
Try:
Code:
  ListView1.SelectAll;
  ListView1.SetFocus;

Hope this helps!

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Stretch is right, although you do not need to use ListView1.SetFocus;

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 

I only have D3 here and the list view has no 'SelectAll' method.
I am sure I tried this with D4 and there was no SelectAll method in that either, is this method a recent addition to the component?


Steve
Those who know me have no need of my name. SD
 
I've got Delphi 7 now and this does have it, I used to use Delphi 5 and I'm pretty sure that had it too. I was thinking about the wrong component when I said you didnt need to put SetFocus; after the SelectAll; you do need to use it.

as for selecting all try this:

Code:
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
for i := 0 to ListView1.Items.Count - 1 do
         ListView1.Items[i].Selected := True;
ListView1.SetFocus;
end;


[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top