Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple Combobox with dropdown
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00724122
Message ID:
00724210
Views:
20
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
------------------
Jose Marcenaro
Tercer Planeta - Argentina
http://www.tercerplaneta.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform