Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generics bound combobox
Message
De
20/09/2007 15:20:25
 
Information générale
Forum:
ASP.NET
Catégorie:
.NET Compact Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01255747
Message ID:
01255819
Vues:
14
>Initially I did it like this:
>   cboRuta.DataBindings.Add("SelectedValue", glRuta, "RutaId");
>But it did not work, however, I feel like I'm missing something.



glRuta is the DataSource for the Combo. It's what fills it's Item list that gets displayed in the DropDown. Because you were trying to set the SelectedValue based on a value in oClient.Ruta, I assumed that you want the syntax I provided ... DataBinding to the SelectedValue using oCliente.Ruta.

Basically, I think that what confuses a lot of people is the Combos (and other controls like ListBox) have two kinds of binding:

The first, setting the DataSource, DisplayMember and ValueMember, tells the Combo what to display in it's DropDown.

The second (adding the binding to the "SelectedValue"), tells the combo where to get it's initial value from and also where to store the value once the user has selected it.

Does that make more sense now?

~~Bonnie




>Initially I did it like this:
>
>
>   cboRuta.DataBindings.Add("SelectedValue", glRuta, "RutaId");
>
>
>But it did not work, however, I feel like I'm missing something.
>
>>I have a quick question as to why you want to set the SelectedValue that way. Are you not binding this Combo to oCliente? If you do this, it should work without manually setting the SelectedValue:
>>
>>
>>cboRuta.DataBindings.Add("SelectedValue", oCliente, "Ruta");
>>
>>
>>~~Bonnie
>>
>>
>>
>>>Hi all, I have a generics list that I use to fill a combobox, I bound them like this:
>>>
>>>
>>>    cboRuta.DisplayMember = "Descripcion";
>>>    cboRuta.ValueMember = "RutaId";
>>>    cboRuta.DataSource = glRuta;
>>>
>>>
>>>That part works fine, but if I set the selectedvalue property it doesn't seems to affect the displayed member of the combobox.
>>>
>>>
>>>    cboRuta.SelectedValue = oCliente.Ruta
>>>
>>>
>>>What am I missing here?
>>>
>>>TIA, Enmanuel
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform