Add items in combobox error
Hi how to add item in combobox when combobox has a set datasource property?
those combobox is datasource enable.. when it display data from the database
but when i add new item i want to those data from datasource is clear and add new items for selection and those are in bold line but it start process to add those item it gives me error "Items collection cannot be modified when the DataSource property is set."
how could i add item to a combobox with an enable datasource property
Code:
Private Sub emptyProject()
dsemails.Clear()
Try
Me.CBOID.DataBindings.Clear()
Me.txtPrjCode.DataBindings.Clear()
Me.txtCat.DataBindings.Clear()
Me.txtAdd.DataBindings.Clear()
Me.txtPrjName2.DataBindings.Clear()
Me.txtPrjName.DataBindings.Clear()
Me.txtPown.DataBindings.Clear()
Me.txtEnd.DataBindings.Clear()
Me.txtStart.DataBindings.Clear()
Me.txtClass.DataBindings.Clear()
Me.txtType.DataBindings.Clear()
Me.txtLink.DataBindings.Clear()
Me.txtPot.DataBindings.Clear()
Me.txtRel.DataBindings.Clear()
Me.txtFin.DataBindings.Clear()
Me.txtDesc.DataBindings.Clear()
Me.txtPval.DataBindings.Clear()
Me.txtFin.DropDownStyle = ComboBoxStyle.DropDown
Me.txtFin.Items.Add("Abroad")
Me.txtFin.Items.Add("Local")
Me.txtClass.DropDownStyle = ComboBoxStyle.DropDown
Me.txtClass.Items.Add("Key Project")
Me.txtClass.Items.Add("Non - key Project")
Me.txtClass.Items.Add("Renovation")
Me.txtClass.Items.Add("Expansion")
Me.txtClass.Items.Add("Maintenance")
Me.txtClass.Items.Add("CES")
Me.txtType.DropDownStyle = ComboBoxStyle.DropDown
Me.txtType.Items.Add("HIGH RISE RESIDENTIAL")
Me.txtType.Items.Add("MEDIUM RISE RESIDENTIAL")
Me.txtType.Items.Add("LOW RISE RESIDENTIAL")
Me.txtType.Items.Add("LOW/MEDIUM RISE RESIDENTIAL")
Me.txtType.Items.Add("RETROFITTING PROJECT")
Me.txtType.Items.Add("INFRASTRUCTURE")
Me.txtType.Items.Add("UTILITIES")
Me.txtType.Items.Add("COMMERCIAL")
Me.txtType.Items.Add("INDUSTRIAL")
Me.txtType.Items.Add("INSTITUTIONAL")
Me.txtCat.DropDownStyle = ComboBoxStyle.DropDown
Me.txtCat.Items.Add("Goverment")
Me.txtCat.Items.Add("Private") Catch ex As Exception
End Try
Re: Add items in combobox error
The error message says it all. You can't add items to a data-bound ComboBox. A bound ComboBox displays the contents of its data source, period. If you want another item then add it to the data source.