#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12

    Maximums Items in a list of a ComboBox ?


    How many can you add ?

    I think there is a limit cause my program bug when I do the loop if he need to enter all the items. It's around 2400, and that's way too many I believe !

    but I have no problems for anything else.

    I just didn't allow the user to add everything in it. But does anyone know what the real maximum ?

    I checked for maxdropdownlist but that's doesn't look like the right thing.
    Last edited by Watever; November 24th, 2003 at 10:17 AM.
  2. #2
  3. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    it must be something on your end, because I just tested (are you using VB or C#?)

    Code:
            For I As Integer = 1 To 20000
                ComboBox1.Items.Add(I)
            Next
    this added 20,000 items to the combobox and they listed fine for me
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    I am with VB

    damn I don't understand why it's not working

    just not that I can't add them. I add them, but look like the program bug, like if it was in a infinite loop and the OS end the program

    I am coding in VB
  6. #4
  7. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    so you're saying the program crashes right, ok then perhaps if you showed your code I we can look at it and try to find the problem, it's always helpful to have someone else look at it, they can find stuff you never thought would be the problem
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    Originally posted by Viper_SB
    so you're saying the program crashes right, ok then perhaps if you showed your code I we can look at it and try to find the problem, it's always helpful to have someone else look at it, they can find stuff you never thought would be the problem
    if you want but I am not sure you will understand it ! ! cause first, most of the variable and comments are in french.

    Code:
        Private Sub CboCritere_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboCritere.KeyUp
    
            mdlFonctions.CompleterListeRecherche(cboCritere, cboChamp.Text.ToLower)
            'Va à la fin du texte du combobox
            cboCritere.SelectionStart = cboCritere.Text.Length
    
        End Sub
    Code:
        Public Sub CompleterListeRecherche(ByRef cboRecherche As ComboBox, ByVal champ As String)
    
            Dim OleDBRech As New OleDb.OleDbCommand()
            Dim OleDatar As OleDb.OleDbDataReader
    
            'La requête pour trouver l'information désiré
            Dim Query As String
    
            'La valeur entrer et que l'on doit rechercher pour suggestions
            Dim MotRech As String = cboRecherche.Text
    
            'Ouverture de la connection si elle n,est pas déjà ouverte.
            If frmItems.OleDbConnection1.State <> ConnectionState.Open Then
                frmItems.OleDbConnection1.Open()
            End If
    
            'efface tous les éléments se trouvant dans la liste au départ pour la recréer
            cboRecherche.Items.Clear()
    
            'Ajoute le caractère '%' qui remplace n'importequel caractère en sql
            If MotRech <> "" And MotRech <> "*" Then
                MotRech = RemplacerCaract(MotRech) + "%"
            Else
                Exit Sub
            End If
    
            If (champ = "ville") Or (champ = "rue") Then
    
                If champ = "ville" Then
                    Query = "select ville from ville where ville like '"
                ElseIf champ = "rue" Then
                    Query = "select rue from rue where rue like '"
                End If
    
                Query += MotRech + "'"
    
            Else
                'Fermeture de la connexion
                frmItems.OleDbConnection1.Close()
                Exit Sub
            End If
    
            'Connexion pour la comm effacer et création de la requête
            OleDBRech.Connection = frmItems.OleDbConnection1
            OleDBRech.CommandText = Query
    
            OleDatar = OleDBRech.ExecuteReader
    
    
            'Lit ligne par ligne les résultats trouvé, met dans un arraylist
            If OleDatar.Read() Then
                Do
                    If champ = "ville" Then
                        cboRecherche.Items.Add(OleDatar.Item("ville"))
                    ElseIf champ = "rue" Then
                        cboRecherche.Items.Add(OleDatar.Item("rue"))
                    End If
    
                Loop Until Not OleDatar.Read
            End If
            'Fermeture de la connexion
            frmItems.OleDbConnection1.Close()
        End Sub
    the problem occurs in the last part, where you have the loop for the OldeDataR. But it's only occurs when it is a "rue" and when it is doing a query that is " like '%' " or %%.

    if you don't understand, don't bother !
    still thank you
    Last edited by Watever; November 24th, 2003 at 12:48 PM.
  10. #6
  11. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    code looks fine, you're basicly taken a bunch of records form a db right and putting them there, have you tried steping through line by line it really helps sometimes.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    I have done it line by line +-. It's in the loop the problem. Look like if it's doing an infinite loop. but I don't know on wich records the problem occurs, if it's change or not.

    I have done the same query with a query record and everything is fine. That's why I tought there was a maximum of items that could be added to a combobox.

    thanx for the help but I think I will let it like that. I just won't allow the user to use the *.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    I found the problem. There is no error in my code or in the database. It's just SLOW. it's take soo much time, that the OS think the program is not doing anything and it is down. but if you wait, it's show it all.

    I don't know how to make it faster, unless I use an American Army computer
  16. #9
  17. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    sounds like a DB problem because that code shouldn't be slow unless it's on a 486
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    Pentium III 733mhz

    yeah may be a db problem I don't know. The query can't be more simple.
    Now it's working, the project is nearly finish and I don't care anymore. They got what they want !

IMN logo majestic logo threadwatch logo seochat tools logo