How to have my Listboxes cooperate?

Posted on 2005-04-13
Last Modified: 2010-04-05
Hi Folks!

I have 2 Listboxes. Each is filled with files. When I select the Nth item of Listbox1 I want that action to select the Nth item of Listbox2 as well.
I need both files to be selected simultaneously cause my procedure depends on both files. Now I numbered all files from 01 to 18 to make things easier, I thought but I have been wrong.




Question by:PeterdeB
    LVL 27

    Accepted Solution

    use the onclick or onChange-event (no delphi on hand yet)

    if sender = ListBox1 then
      ListBox2.itemIndex := ListBox1.ItemIndex
      ListBox1.itemIndex := ListBox2.ItemIndex;

    just from head, means not tested and typos possible

    meikl ;-)
    LVL 1

    Expert Comment

    What do you want to happen if listbox2 is clicked?
    LVL 27

    Expert Comment

    >What do you want to happen if listbox2 is clicked?

    must explain my suggestion  :-)
    the described eventhandling is thought to assign it to both listboxes,
    so it shouldn't matter which box was clicked

    meikl ;-)

    Author Comment


    Regards Peter

    (I set it to the onchange event btw since the onclick didnt feel like cooperating :))

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    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…

    729 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

    18 Experts available now in Live!

    Get 1:1 Help Now