Solved

TListView virtual mode & Selected

Posted on 2002-05-23
7
456 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
Independent Software Vendors: 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
select query - oracle 16 103
Delphi: barcode reading on android platform 1 99
Microsoft Access 97 and Delphi XE2 9 85
Formating a integer number to float 2 6
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…

734 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