The error message explains the problem. If you set the Datasource property, like if you bind it, then you can't use the Items.Add method to add items to the items collection.
If you have the ComboBox bound to a field in a datatable then you would need to add the new item to the datatable and it would automatically be added to the combobox items list.
Bind the combobox
Then to add to the items list,Code:Me.ComboBox1.DisplayMember = "name" Me.ComboBox1.ValueMember = "name" Me.ComboBox1.DataSource = dt
Code:Dim row = dt.NewRow row("name") = "testcb" dt.Rows.Add(row)




Reply With Quote
