Combo Box Error - Too Many items in the combo box

Hi Guys,

I am receiving the error listed on the subject. The error message is pretty obvious, but the question is:

How many items can I add to a ComboBox   In my case the number is > 32800....

Do exist any difference depending on the Operating System   My App is running on Windows 98.


Answer this question

Combo Box Error - Too Many items in the combo box

  • Andrew D

    I don't know what the maximum is, but why are you trying to put so many in a combo box. Even if you are writing some kind of mechanism that the user can use to navigate through so many options you're taking up a ton of memory that almost certainly is doing you or the user no good.

    Hopefully there is a better way to do what you want.

    Don

  • ianhoc

    Well, it seems to be limited only by resources. I put together a simple example:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    For i As Int32 = 1 To 1000000
    ComboBox1.Items.Add("Item " & i.ToString)
    Next
    End SubAdding a million items took a while, but it worked fine. I tested it on a machine with some 700+ megs of memory. Upon completion, the app took up about 106 megs in memory, according to task manager. I could scroll the list, select items, everything I'd expect, although it was a bit sluggish.

    Granted, this is just adding short text strings, so it's taking up minimal memory for each object. What kind of objects are you adding  And what kind of memory does the client have

    At this point, I would guess that the combobox is smart enough to see that it's running out of resources and surmise that it's because you've added too many items. 

    So the solution is probably to catch and handle the error, telling the person to hit a sale at Best Buy for more memory, unless you have any additional information about the error. If you do, please post it along with the <i>complete</i> exception message and stack trace.

    Don

  • Jaylou

    Yes, sure there is. The App wasn't made to have all this amount of data in this combobox, but ONE customer have this too many data. Since the App is generic, he can put anything HE wants there.
  • geometrikal

    Sigh. I hate it that the customer is always right.

    Okay, I'll see what I can dig up. In the meantime, hopefully someone else has an answer.

    Don

  • Combo Box Error - Too Many items in the combo box