Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TListView - TopItem

223 views
Skip to first unread message

Peter Gore

unread,
Nov 25, 2001, 1:39:17 AM11/25/01
to

How can I set the TopItem property of a TListView?

Florian Haag

unread,
Nov 25, 2001, 4:36:54 AM11/25/01
to
Peter Gore <pe...@gorehome.freeserve.co.uk> schrieb in im Newsbeitrag:
3c009215$1_1@dnews...

>
> How can I set the TopItem property of a TListView?

Hi,
you could try to use ViewOrigin property along with Scroll method
of TListView to make a certain item the first one that's visible.

HTH
(
--
Florian Haag
ICQ: 114504497
http://private.addcom.de/h/haag/fh/

Rudy Velthuis (TeamB)

unread,
Nov 25, 2001, 5:36:44 AM11/25/01
to
In article <3c009215$1_1@dnews>, Peter Gore says...

> How can I set the TopItem property of a TListView?

Not sure. But if you are only trying to make sure that a certain item is
visible, use TListItem.MakeVisible.

Of course you can use the value in TopItem (or use the message
LVM_GETTOPINDEX to get the top index) and then scroll up or down.
--
Rudy Velthuis (TeamB)

Peter Below (TeamB)

unread,
Nov 25, 2001, 6:09:31 AM11/25/01
to
In article <3c009215$1_1@dnews>, Peter Gore wrote:
> How can I set the TopItem property of a TListView?

There is no direct way to do that. YOu can use a TLIstitems MakeVisible
method to scroll it into view, but you have no control over where it
will end up.

You can "manually" scroll the listview by sending it WM_VSCROLL
messages:

Procedure ScrollItemtoTop( lv: TLIstview; index: Integer );
var
num: Integer;
scrollcode: Integer;
begin
num := lv.TopItem.Index - index;
If num < 0 Then Begin
scrollcode := SB_LINEDOWN;
num:= Abs(num);
End
Else
scrollcode := SB_LINEUP;
lv.Items.BeginUpdate;
Try
While num > 0 Do Begin
lv.Perform( WM_VSCROLL, scrollcode, 0 );
Dec(num);
End;
lv.Perform( WM_VSCROLL, SB_ENDSCROLL, 0 );
Finally
lv.Items.EndUpdate;
End; { Finally }
end;


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Grinder

unread,
Nov 25, 2001, 7:14:51 PM11/25/01
to
The other posts have more complete approaches--but I have a
quick and dirty routine that's fairly workable:

ListView.Items[iTopRow +
ListView.VisibleRows].MakeVisible(False);
ListView.Items[iTopRow].MakeVisible(False);


"Peter Gore" <pe...@gorehome.freeserve.co.uk> wrote in message
news:3c009215$1_1@dnews...

0 new messages