Select item above or below in listview

Posted on 2005-04-13
Last Modified: 2010-04-04
Hi there,

I have a Listview component, with 5 items in it, when I select say, the 3rd item I want a button that I can click to move the selection pointer (not the item) up or down. So basically it just moves up or down the list - not the item, just the selection.

I tried lvItems.selected.index + 1 but that didn't work.

Many thanks
Question by:wildzero
    LVL 19

    Accepted Solution

    Bah! My Delphi is rusty... Try setting the selected property of the individual item to true.  Off the top of my head (I don't have Delphi to hand and rely far too much on the auto-features of Delphi!) try something like:

    lvitems.items[lvitems.selected.index + 1].selected := true;

    Again, apologies for the rustiness!
    LVL 15

    Expert Comment

    lvItems.Items[lvItems.ItemIndex-1].Selected := True;
    lvItems.Items[lvItems.ItemIndex+1].Selected := True;
    LVL 10

    Author Comment

    Awesome :-)
    Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now