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 change the position of a list item in a TListView (4) 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
105
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I want to keep one row as the topmost visible row in a TListView. Each time it will 
vary according to my search, which one I found I want to make that one as a topmost 
row. How can I do this?

Answer:

Scroll a listview item to the top:

1   procedure ScrollItemtoTop(lv: TLIstview; index: Integer);
2   var
3     num: Integer;
4     scrollcode: Integer;
5   begin
6     num := lv.TopItem.Index - index;
7     if num < 0 then
8     begin
9       scrollcode := SB_LINEDOWN;
10      num := Abs(num);
11    end
12    else
13      scrollcode := SB_LINEUP;
14    lv.Items.BeginUpdate;
15    try
16      while num > 0 do
17      begin
18        lv.Perform(WM_VSCROLL, scrollcode, 0);
19        Dec(num);
20      end;
21      lv.Perform(WM_VSCROLL, SB_ENDSCROLL, 0);
22    finally
23      lv.Items.EndUpdate;
24    end;
25  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