-
DropDownList
Basically I am trying to write a simple conversion tool. Take x amount of feet and convert that into y amount of meters and vice versa. I am using a whole bunch of different measurements so I decided to use two comboboxes as dropdownlists. Basically, if the user inputs 5 they can then easily select meters to feet or feet to meters, etc.
I have my equation written but can not figure out for the life of me how to assign a value or key to the items in my dropdownlist. I am using visual studio .net. I populated my list originally using the List Property. How do I give those a property? Say I want Meters to equal sngMet in my code. How would I do that?
I need to Populate the two lists, give each item in the list a unique ID, tie that id to a value and then insert that value into an equation.
If you couldn't tell by now, I am a noobie. I am just at the point that looking at this any longer will make me mad! I've tried to RTFM but its a POS.
Thanks,...
-
Here's a sample of the code I am using. The problem is that I can't call my "Item.Key" later in the program. The "Item.Value" prints fine. The "Item.Key" string comes up blank:
<vb code>
Dim mySortedList as new System.Collections.SortedList
Dim Item as DictionaryEntry
mySortedList("sngMet") = "Meters"
mySortedList("sngIn") = "Inches"
mySortedList("sngFt") = "Feet"
mySortedList("sngCm") = "Centimeters"
For each Item in mySortedList
Dim newListItem as new ListItem()
newListItem.Text = Item.Value
newListItem.Value = Item.Key
DropDownList1.Items.Add(newListItem)
Next
</vb code>
-