Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TListView virtual mode & Selected

Posted on 2002-05-23
7
Medium Priority
?
467 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
Technology Partners: 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 200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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