Refreshing a ComboBox

  • 15 years ago

    I have a ComboBox and any time one is selected I have a question that if another one should be selected
    then after the ComboBox should have one selection less....! I implemented the

    MyCommand = "SELECT Table_Cartes.Carte_Nom FROM Table_Cartes " & _
                               "WHERE Table_Cartes.Carte_Nom NOT IN (SELECT " & _
                               "Table_Employés_Cartes.Employés_Cartes_Nom FROM " & _
                               "Table_Employés_Cartes WHERE " & _
                               "Table_Employés_Cartes.Employés_Cartes_ID = " & " '" & TextBoxMatricule.Text & "')"

    But, it still shows me the whole list....I think I should clean or clear the ComboBox before calling the query.

    My question is I have no idea how to clear or clean the ComboBox....I can't find the method on books or web

    Thank you

  • 15 years ago

    in .net u will find that most/all controls will have an Items object from which all methods below are the same across controls, so the same for a combobox as is the same for a list box etc, they all have the same member .Clear() .ADD() .Count() etc etc

    to clear your box do :


  • 15 years ago

    Thank you Rollershade!   I used that....but is my mistake...I did not explain myself correctly....!

    I used as a fill method the:

    daCombo.Fill(dsCombo, "Cartes")

    With ComboBox
           .DataSource =  dsCombo.Tables("Cartes")
           .DataMember = "CarteNom"
           .valueMember = "Carte
    End With          

    So, when I want to select another one from the list, I confirmed with an ADD button and it is there where I want that list to decrease by the one selected.....I used the ComboBox.Items.clear() and I got an error because the .DataSource is used to fill the ComboBox.....!

    Any idea?                            

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Brevity is the soul of wit” - Shakespeare