Automatically add item to combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    Automatically add item to combo box

    From what i know, to do this you bind a combo to a datatable.
    (so the data keeps even when the file is shut)
    You then add code that tells the combo box to add a new row with the data typed into the combo box ie the text if the datatable does not allready contain the typed text.
    Ps i use visual basic 2008 express version
    What code would be used if it has been bound to a datacolumn called :
    dataset1.datata ble1.column1
    assuming the combo box is called : combobox1
    From what i tried i managed to get this :
    Code:
    Private Sub ComboBox1_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus
            If Not DataTable1.Rows.Contains(ComboBox1.Text) Then
                DataTable1.NewRow()
    
    
                Exit Sub
            End If
            ComboBox1.Refresh()
        End Sub
    Thanks for any help
Working...