Board index » delphi » TListView - column clicking and scrolling to selected item

TListView - column clicking and scrolling to selected item

I'm using D5 Enterprise.

When using a TListView (in report style with columns), sometimes there's a need to internally select
an item (ListView.Selected := ... ).  If this item is near the bottom of the list, how do I tell the
ListView to scroll to that item?  I've tried Scroll and ScrollBy, but nothing works.  I've even
tried FindCaption() hoping it would automatically scroll, but no good.

Also, I have code to sort the ListView depending on the column clicked.  I have a special case where
I need to internally sort a column.  There isn't a ListView.Columns[1].Click or something.  Any
ideas?

--
Thanks,
Jon.

 

Re:TListView - column clicking and scrolling to selected item


Quote
>how do I tell the ListView to scroll to that item?

Look at:

    ListView1.Selected.MakeVisible(False);

Quote
>I need to internally sort a column.

You should be able to execute the custom sort method from anywhere, not just
the click method.

    ListView1.CustomSort(@MYSortFunction, MyColumnIndex)

-Steve-

Re:TListView - column clicking and scrolling to selected item


Quote
>how do I tell the ListView to scroll to that item?

Look at:

    ListView1.Selected.MakeVisible(False);

Quote
>I need to internally sort a column.

You should be able to execute the custom sort method from anywhere, not just
the click method.

    ListView1.CustomSort(@MYSortFunction, MyColumnIndex)

-Steve-

Re:TListView - column clicking and scrolling to selected item


Quote
In article <7vci6f$2...@forums.borland.com>, Jon E. Scott wrote:
> When using a TListView (in report style with columns), sometimes there's a need to internally select
> an item (ListView.Selected := ... ).  If this item is near the bottom of the list, how do I tell the
> ListView to scroll to that item?

This is OOP <g>, so you tell the *item* to make itself visible: use the
listitems MakeVisible method.

Quote
> Also, I have code to sort the ListView depending on the column clicked.  I have a special case where
> I need to internally sort a column.  There isn't a ListView.Columns[1].Click or something.  Any
> ideas?

But there is a TListview.OnClick. In it you can get the mouse position, convert it
to the listviews client coordinates figure out where the user clicked by using
the listviews GetHittestInfoAt and GetNearestItem methods.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads