Results 1 to 6 of 6

Thread: Listbox question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Listbox question

    Hi,

    I wanted to load a lot of items into the listbox and found out its limitation i.e I try to load 1000 lines of long words, it hit to the max.

    So my questions:

    Is it possible to bypass the max size limitation or is there other control that can handle better than listbox?

    Can I load from an external CSV or Excel file and display in a way like every row will show from 1 to 1000 and I would set the value in the background means 1 stands for ABCDEFG.

    Please advise

  2. #2
    Addicted Member
    Join Date
    Jan 2008
    Location
    Tennessee
    Posts
    130

    Re: Listbox question

    Have you considered using a DataGridView control? The columns in that control can be configured in many ways. I've even used it once to create a simple column of buttons whose captions came from a db. It's more complex than a listbox, but pretty powerful.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Listbox question

    Regardless of what you wind up using, 1000 items is a lot to go through....can't you filter the entries in some logical manner?

  4. #4
    Addicted Member
    Join Date
    Jan 2008
    Location
    Tennessee
    Posts
    130

    Re: Listbox question

    Hack is right about filtering entries. It could improve performance, not to mention user-friendliness.

    I didn't think that the listbox had a limit, so I created a quick little test and got up to 100,000 lines added to it. It's not fast and definitely not ideal, but proves that there shouldn't be a limit.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Listbox question

    Thanks for replying. Will explore on datagridview.

    My reason was that the program I create need to process thousands item every seconds and display to the user what the current item that it process. So my timer will make the listbox select to next item every second.

    You can get to 100,000 lines is it because every line, you only have a few character?

  6. #6
    Addicted Member
    Join Date
    Jan 2008
    Location
    Tennessee
    Posts
    130

    Re: Listbox question

    I realized that the Listbox uses an ObjectCollection to store its list items. So I couldn't think of any reason why it should have any sort of limitations. So to ensure there wasn't any sort-of property mechanism that would limit it, I ran a quick test with a sentence and looped through 100,000 times. As I said before, this wasn't to represent the efficiency of doing this, just prove a point. If I had complex results, and many of them, to which displaying them is necessary, I would consider using a DataGridView control. It can be populated manually, or bound to a datasource such as a DataTable, etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width