I am having a list of items in combo box. in runtime if user feels to add new item to combo list he should be allowed to do the same just by typing new item in combo box typing area

Recommended Answers

All 4 Replies

That's not how a combo box works. You could provide a textbox and an ADD button to do that though.

no other go!!!!

i was trying if i miss something...... thanks :)

Actually you can do that all you need is a button(to signify when the typing is done) and a handler for its click event:

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    If ComboBox1.Text <> "" AndAlso Not ComboBox1.Items.Contains(ComboBox1.Text) Then
        ComboBox1.Items.Add(ComboBox1.Text)
        ComboBox1.ResetText()
    End If
End Sub
commented: Perfect to do that +7

Or you can do it with ComboBox1's LostFocus Event

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.