Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Databinding a Combobox in c#
Message
De
23/03/2003 10:27:22
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00767936
Message ID:
00769039
Vues:
23
Fred,

I haven't figured out how to use a 2 dimensional array as the DataSource for a combo, because I don't know how you would set the ValueMember. There may be some way to do it, but I don't know what it is if there is one.

I've done it with a 1 dimensional array, but that will only work if you're binding to the Text which I was (and in your example, you're not). That's why I recommended creating a 2-column DataTable for your DataSource. Then you can bind to the SelectedValue instead of to the Text.

~~Bonnie


>if I have a 2 dime array what do i bind it to in the combobox? value, valuemember,displaymember, text ?
>
>Regards,
>
>
>>Fred,
>>
>>The problem with binding to a one-dimensional array ... you have something to display, but not to bind an integer value to. Try creating a DataTable with two columns to fill the combo with.
>>
>>~~Bonnie
>>
>>
>>>Hi guys,
>>>I have a combo box on a windows form. It is populated with an arraylist
>>> private ArrayList laarraylist
>>>laarraylist = new ArrayList()
>>>laarraylist.Add("Weekly");
>>>laarraylist.Add("Monthly");
>>>laarraylist.Add("Yearly");
>>>
>>>ComboBox1.DataSource = laarraylist
>>>
>>>I have a Dataset with an integer field. the field can be 1,2 or 3.
>>>
>>>How do I bind the data from the dataset to the combobox.
>>>
>>>I have tried the foll
>>>
>>>ComboBox1.DataBindings.Add(new Binding("Text",ds,"Client.Period"))
>>>
>>>when I view the form the Combo box is always displaying the first item (Weekly"). can Anyone see anything wrong with this code. I need your help please .
>>>
>>>Regards,
>>>
>>>Fred
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform