Hi Roland
It's a two step operation
1. Filling the combo with the fixed items
2. Binding the selected value to the dataset field
You can do each of them on the designer, assigning values to:
1. The Items collection property of the combo
2. The DataBindings extended property (SelectedValue)
Or you can just do it in code (BTW, that's what the designer does for you):
comboBox1.DataBindings.Add(
new System.Windows.Forms.Binding(
"SelectedValue", myDataSet, "Employee.Prefix"));
comboBox1.Items.AddRange(new object[] {
"Mr",
"Mrs",
"Miss",
"Ms"});
Then whenever myDataSet contents change (i.e. after reading existing values) you should call
comboBox1.Refresh();Regards,
Jose.
>Hi,
>
>This is simple but can someone explain to me how to set the properties for a combobox with Items (Collections)
>
>Mr
>Mrs
>Miss
>Ms
>
>and bind it to a field in a dataset,table.
>
>I tried to bind the field to the selecteditem but it will not updated the field or pick up the field value when the form is first displayed.
>
>Thanks
>Roland