-
Oct 30th, 2018, 05:36 PM
#1
Thread Starter
Junior Member
Adding Values to a Dictionary
I have a dictionary - myDict(Of Button, string)
I have an xml file with elements of "Page", "ID" and "Info" - for each page there are are a number of IDs relating to the key/button; also a number of Infos as strings.
The difficulty I'm having is figuring out how to either:
* Load the ID.innertext into the key (and then the Info into the value), OR
* (having preloaded the keys with button objects) relate the ID nodes to the relevant keys so that I can change the values.
Perhaps this can be summarised as converting a string to a button; or being able to save a button to xml.
All suggestions very gratefully received.
Thanks.
-
Oct 30th, 2018, 05:43 PM
#2
Re: Adding Values to a Dictionary
Maybe your Dictionary should be using a different type as the key. If you want to stick with Button then you could assign the ID to the Tag property of each Button. You're likely going to have to loop through the Keys to find a match then though, so you rather lose the advantage of a Dictionary. How about a Dictionary(Of String, Button) to relate the IDs to the Buttons first? Then you can go from ID to Button to the rest of the data.
-
Oct 30th, 2018, 06:34 PM
#3
Thread Starter
Junior Member
Re: Adding Values to a Dictionary
Originally Posted by jmcilhinney
Maybe your Dictionary should be using a different type as the key. If you want to stick with Button then you could assign the ID to the Tag property of each Button. You're likely going to have to loop through the Keys to find a match then though, so you rather lose the advantage of a Dictionary. How about a Dictionary(Of String, Button) to relate the IDs to the Buttons first? Then you can go from ID to Button to the rest of the data.
Thank you, the trouble is that I'm making big changes to implement dictionaries that will make big improvements in this form. I guess a slower population is worth the saving that will follow when the dictionary is being used.
The number of keys is fixed so I've been wondering if I can use the IDs as Select Case... A big clunky, but should work.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|