dcsimg
Results 1 to 3 of 3

Thread: Adding Values to a Dictionary

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    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.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,585

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    Re: Adding Values to a Dictionary

    Quote Originally Posted by jmcilhinney View Post
    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
  •  



Featured


Click Here to Expand Forum to Full Width