Solved

TListView virtual mode & Selected

Posted on 2002-05-23
7
458 Views
Last Modified: 2008-02-01
I have a TListView in virtual mode. I set the Selected property to an item outside the current listbox. If U scroll down the list I can see the new item selected ?_but_ how can I get the list box to automatically move it's view on the TCollection down to include the new selected (via code) item.

Thanks, Tom.
0
Comment
Question by:tomcorcoran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7031077
try something like this?

ListView1.Items[myIndex].MakeVisible(False);

or

ListView1.TopItem := ListView1.Items[myIndex];
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7031201
I'm not sure whether the "Items" property works completely, when using virtual mode. I'm using the following function when doing virtual mode:

ListView_EnsureVisible

Regards, Madshi.
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7031279
Hmm... yeah, forgot about that.

Didn't try it myself, but you just *might* get a List Index Out of Bounds error.

So Tom, Madshi is correct, just follow his suggestion and call it this way:

ListView_EnsureVisible(ListView1.Handle, myIndex, False);

and don't forget to add CommCtrl in your uses clause.

(PS: If this works, give the points to Madshi)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 7031305
The Items stuff might work, too, sometimes it does work even in virtual mode. Just not sure...
0
 

Author Comment

by:tomcorcoran
ID: 7031676
It turns out that
ListView1.Items[myIndex].MakeVisible(False);
is a wrap for
ListView_EnsureVisible(ListView1.Handle, myIndex, False);
so both work perfectly :-)
There doesn't seem to be any advantage to using the later.

FYI, ListView1.TopItem is readonly.

The selected index however shows at the bottom of the TListView and I want it toward the top. I want to do

ListView1.Items[myIndex+NumberItemsVisibleInList].MakeVisible(False);

Do ye have any idea how I can get
the number of items visible in the list?

Thanks a million, Tom.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7032077
ListView_GetCountPerPage
0
 

Author Comment

by:tomcorcoran
ID: 7041280
Thanks for you guys help. Great, Tom.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question