add item to comboBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, All,

when starting run app, how to let user add item/edit item to comboBox on the
Form,

Thanks,
Martin
 
I'm not sure how you initially fill the combobox, but the user can add items
like the following and then tie in with list or database at the same time.

Lennart

Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
If e.KeyCode = Keys.Enter And ComboBox1.Text IsNot Nothing Then

ComboBox1.Items.Add(ComboBox1.Text)

ComboBox1.Text = Nothing

End If

End Sub
 
hi, Lennart,

Thanks. One more question - after add there, how to edit/remove item from
list?

Martin
 
Martin,

As far as I know, your only choice is to do those as separate operations.
You can for example use a right-click on the combobox to open a
contextmenustrip with an Edit and a Delete item.

With the delete item you can do combobox1.items.remove(combobox1.text).

Editing an item could be a two-step function where you "edit" the item in a
userbox, then delete the original and replace it with the edited version.

Lennart
 
Thank you
Martin

Lennart Nielsen said:
Martin,

As far as I know, your only choice is to do those as separate operations.
You can for example use a right-click on the combobox to open a
contextmenustrip with an Edit and a Delete item.

With the delete item you can do combobox1.items.remove(combobox1.text).

Editing an item could be a two-step function where you "edit" the item in a
userbox, then delete the original and replace it with the edited version.

Lennart
 
Back
Top