Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to search up and down in a TListView Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
31-Oct-02
Category
VCL-General
Language
Delphi 2.x
Views
52
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to search up and down in a TListView

Answer:

1   procedure TRememberMenu.FindDialog1Find(Sender: TObject);
2   var
3     MaxLines, Adder, CurrentLine, X: Integer;
4     LookText: string;
5     Found: Boolean;
6   begin
7     {Find the word}
8     Found := False;
9     MaxLines := ListView1.Items.Count - 1;
10    LookText := UpperCase(FindDialog1.FindText);
11    if ListView1.Selected <> nil then
12      CurrentLine := TListItem(ListView1.Selected).Index
13    else
14      CurrentLine := 0;
15    X := CurrentLine;
16    if frDown in FindDialog1.Options then
17    begin
18      Adder := 1;
19    end
20    else
21    begin
22      Adder := -1;
23    end;
24    X := X + Adder;
25    if (X >= 0) and (X <= MaxLines) then
26    begin
27      repeat
28        begin
29          if Pos(LookText, UpperCase(ListView1.Items[X].Caption)) <> 0 then
30          begin
31            Found := True;
32            ListView1.Selected := nil;
33            ListView1.Selected := ListView1.Items[X];
34            ListView1.Items[X].MakeVisible(False);
35            ListView1.SetFocus;
36          end;
37          X := X + Adder;
38        end;
39      until
40        (X > MaxLines) or (Found) or (X < 0);
41    end;
42    if Found = False then
43    begin
44      SoundBeep;
45    end;
46  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC