Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox making a list

Status
Not open for further replies.

mechInferno

Technical User
Oct 24, 2005
24
CA
Hi everyone,

I am trying to remember how to enter a value in the textbox portion of a combobox, then check the combo list to see of it is there and if it is not have it enter into the list. I want to have this happen when the enter key is pressed.

Any help would be great.

Stupidity, the greatest drug. haha :(
 
Code:
    Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _
    Handles ComboBox1.KeyDown

        If e.KeyCode = Keys.Enter Then
            Dim s As String = Me.ComboBox1.Text
            If Not Me.ComboBox1.Items.Contains(s) Then
                Me.ComboBox1.Items.Add(s)
                MessageBox.Show("Item Added !")
            Else
                MessageBox.Show("Not Added .")
            End If
            Me.ComboBox1.Text = String.Empty
        End If

    End Sub


:)
 
Thanks for your reply,

I just got the exact same thing like 3 hours ago. I just had to try and remember it.


Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top