Getting the listBox item at a given index location

Posted on 2004-11-21
Last Modified: 2010-04-15
I have trouble getting the object associated with the given index of a listBox, unles I explicitly set the index ahead of time.

For example, I need to ...

listBox.SeletedIndex = 1;
Object object = listBox.SelectedItem

The problem with this is that you can see the listBox scroll through the choices, and it looks dumb.  

How do I simply get the item at a known index location.

Question by:ba272
    1 Comment
    LVL 3

    Accepted Solution


    ListBox.Items[k], where k is the known index location.

    For example,

                      int pos = listBox1.Items.Count-2;
                      string selItem = listBox1.Items[pos].ToString();

    you will not see any flicker or scrolling - I tested with at 25553-item list box

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    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…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    761 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

    11 Experts available now in Live!

    Get 1:1 Help Now