Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jump to row in ListView

Posted on 1999-07-29
7
Medium Priority
?
263 Views
Last Modified: 2010-04-04
How do I jump to a specific row in a ListView?
(For example: I have 200 rows and 1-20 are showing but when I press a button I want to skip to row 67)
0
Comment
Question by:jonassondaniel
[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
7 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391881
This will do:

ListView1.Items[67].Selected := true;


Regards,

Epsylon.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1391882
hji epsylon,
i was trying  to do that and it wouldnt work??
i ended up having to do this:

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
i:=67;
listview1.Items.Item[i].EditCaption;
listview1.items.Item[i].CancelEdit;
end;

Regards Barry
0
 

Author Comment

by:jonassondaniel
ID: 1391883
Like INTHE says it isn't enough to set selected to true, or even focused.

However, INTHE, your suggestion might work but there must be a more "correct" way of doing this... Please anyone??
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 1391884
hi all,

what about

procedure TForm1.Button1Click(Sender: TObject);
begin
  ListView1.Selected := Listview1.Items.Item[67]; //if ot should be selected
  Listview1.Items.Item[67].Makevisible(False);     //Show it
end;

meikl
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391885
What about this then:

with ListView1 do
begin
  Items[67].Selected := true;
  Scroll(0, Selected.Position.y - TopItem.Position.y);
end;

0
 

Author Comment

by:jonassondaniel
ID: 1391886
Both kretzschmar's and Epsylon's suggestion seems to work. The difference is that Epsylon's way puts the item at the top of the list instead of kretzschmar's way that puts it on the bottom. I think Epsylon's way is more convenient so please, propose answer so that I can reward you. Thank you all for the help!
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 60 total points
ID: 1391887
So the answer is.....


This will put item 67 at the top of the listview:

with ListView1 do
begin
  Items[67].Selected := true;
  Scroll(0, Selected.Position.y - TopItem.Position.y);
end;


Thanks for the points   :o)

Epsylon.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
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…
Suggested Courses

670 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