Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to store hand-typed combobox values
Message
De
25/07/2003 20:17:48
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00813616
Message ID:
00813677
Vues:
7
Don,

I guess my point was that because you set the DisplayMember as you did (using the Bound table instead of the DataSource), perhaps *that's* what's keeping it from working correctly with the hand-typed value. At least that was my original point, but now that I think about it, it's probably because what you're typing in is the DisplayMember, but because you're typing it in there, you're not giving it any kind of corresponding value to go with it.

IOW, say you're displaying state names and your value is the two character state abbreviation. Even if you type in a two character abbreviation into your combo box, it's probably being interpreted as the DisplayMember and not the ValueMember. I'm probably not explaining it too well and I may even be wrong.

I haven't used a ComboBox in this manner, so I don't know if I'm all that much help. Maybe someone else could jump in here and help out.

~~Bonnie


>Thanks Bonnie, but I don't seem to have any problem using an arraylist if I use the sample from the Help screens that creates individual State objects with properties, then add thos objects to the "States" Arraylist. That part seems to work fine, I just want to know how to store hand-typed values. You see what I mean - like when you use the keyboard to type into the combobox rather than picking an item from the dropdown list with the mouse.
>
>Is there some code I need to enter to cause hand-typed ComboBox values to be stored? Everything else works as advertised.
>
>
>>Don,
>>
>>Typically the .DisplayMember will be from the DataSource, not from the Bound data. I'm assuming that you did it this way because your arraylist has only one dimension. I've not found an easy way to use an array as a DataSource when your DisplayMember and ValueMember are two different things (I may be missing something) ... in those cases, I've just built a Table instead of an Array and used the Table for the DataSource.
>>
>>~~Bonnie
>>
>>
>>>I have a combobox bound to a dataset field, with a rowsource set to an arraylist of objects containing state abbreviations. The dropdownstyle property set to "Dropdown" so I can type in a value in the textbox area.
>>>
>>>When I select an item from the Dropdown list my data can be saved to the dataset and works as expected. But when I hand-type a value (even if it matches an item in the dropdown list) nothing is changed when I save the dataset.
>>>
>>>Can someone see what I am missing in the following code? What do I need to change for hand-typed entries in the combobox
>>>
>>>******************************
>>>With Me.cboStates
>>> .DataBindings.Clear()
>>> .DataSource = States ' States is an arraylist
>>> .ValueMember = "ShortName" ' A property of arraylist objects
>>>
>>> .DisplayMember = dsCompanyInfo.Tables("CompanyInfo").Rows(0).Item("State")
>>> .DataBindings.Add("SelectedValue", dsCompanyInfo.Tables("CompanyInfo"), "State")
>>>End With
>>>******************************
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