Adding Items to data-bound Combo Box
-
Hello! In my data entry form, all the fields are bound to a tblStaff table through BindingSource (staffInfoBS). One of these controls is a cboGender ComboBox. I want to manually populate the cboGender with only two items -- "Male" and "Female" and the SelectedValue be saved in the underlying table. If I try to use something like Items.Insert, I receive error: Items collection cannot be modified when the DataSource property is set. How can get it done. Please suggest.
-
Hello! In my data entry form, all the fields are bound to a tblStaff table through BindingSource (staffInfoBS). One of these controls is a cboGender ComboBox. I want to manually populate the cboGender with only two items -- "Male" and "Female" and the SelectedValue be saved in the underlying table. If I try to use something like Items.Insert, I receive error: Items collection cannot be modified when the DataSource property is set. How can get it done. Please suggest.
You either have to have items in the datasource that your combo seems to be bound to or you have to scrap the binding on the combo and put the items in yourself. You can't have both.
A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak