Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Is an Array of Dictionaries the solution here?

Is an Array of Dictionaries the solution here?

Scheduled Pinned Locked Moved C#
questionhelpwindows-admindata-structurestools
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheBlindWatchmaker
    wrote on last edited by
    #1

    Hi all, First some context to my question: I am working on a utility that queries the Windows registry for a large number of keys set by a particular application. I am using multiple DataGridView (DGV) controls to display the information (Reg Key and Value) on my form. Each DGV is tied to a Dictionary using a BindingSource. This has worked out fine for all sets of keys except for one. - This application has provision for 10 different user-profiles. - Associated with each user-profile are 7 SETS of feature keys. - At any given time, the user needs to see the settings for only ONE of the 10 profiles. - On my form, I have a collection of radiobuttons that I use to select a profile. PROBLEM: 1. Should I use an array of dictionaries (dimension 1: profile; dimension 2: feature)? If so, how do I do this? If not, what is a better solution? 2. Can I have only 1 set of DGVs (representing the feature keys), so when I click between profiles, the DGVs are updated with the values for that profile? Thanks for your help!

    P B 2 Replies Last reply
    0
    • T TheBlindWatchmaker

      Hi all, First some context to my question: I am working on a utility that queries the Windows registry for a large number of keys set by a particular application. I am using multiple DataGridView (DGV) controls to display the information (Reg Key and Value) on my form. Each DGV is tied to a Dictionary using a BindingSource. This has worked out fine for all sets of keys except for one. - This application has provision for 10 different user-profiles. - Associated with each user-profile are 7 SETS of feature keys. - At any given time, the user needs to see the settings for only ONE of the 10 profiles. - On my form, I have a collection of radiobuttons that I use to select a profile. PROBLEM: 1. Should I use an array of dictionaries (dimension 1: profile; dimension 2: feature)? If so, how do I do this? If not, what is a better solution? 2. Can I have only 1 set of DGVs (representing the feature keys), so when I click between profiles, the DGVs are updated with the values for that profile? Thanks for your help!

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2
      1. The registry is evil, don't use it. 1) DataGridView is evil and likely an inappropriate control for your purpose. 2) The registry is a tree, why not use a TreeView?
      T 1 Reply Last reply
      0
      • T TheBlindWatchmaker

        Hi all, First some context to my question: I am working on a utility that queries the Windows registry for a large number of keys set by a particular application. I am using multiple DataGridView (DGV) controls to display the information (Reg Key and Value) on my form. Each DGV is tied to a Dictionary using a BindingSource. This has worked out fine for all sets of keys except for one. - This application has provision for 10 different user-profiles. - Associated with each user-profile are 7 SETS of feature keys. - At any given time, the user needs to see the settings for only ONE of the 10 profiles. - On my form, I have a collection of radiobuttons that I use to select a profile. PROBLEM: 1. Should I use an array of dictionaries (dimension 1: profile; dimension 2: feature)? If so, how do I do this? If not, what is a better solution? 2. Can I have only 1 set of DGVs (representing the feature keys), so when I click between profiles, the DGVs are updated with the values for that profile? Thanks for your help!

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        The keys you are looking up (for each dictionary) are just within one registry node, right? Otherwise the above advice is correct, you should use a control with tree capabilities. A list of dictionaries is probably appropriate. You can only have one set of controls, and switch their data sources when the profile changes.

        T 2 Replies Last reply
        0
        • P PIEBALDconsult
          1. The registry is evil, don't use it. 1) DataGridView is evil and likely an inappropriate control for your purpose. 2) The registry is a tree, why not use a TreeView?
          T Offline
          T Offline
          TheBlindWatchmaker
          wrote on last edited by
          #4

          PIEBALDconsult wrote:

          The registry is evil, don't use it.

          Unfortunately, I have to :)

          class="FQA">PIEBALDconsult wrote:

          1. DataGridView is evil and likely an inappropriate control for your purpose.

          Not sure why the DGV is so evil but it does work quite nicely for the purpose of my project.

          PIEBALDconsult wrote:

          1. The registry is a tree, why not use a TreeView?

          I will look into using a TreeView... I did not know about this when I started working on my utility and I have the information displayed the way it is required. However, it might not be too late to rethink this design... thanks for the tip! :)

          1 Reply Last reply
          0
          • B BobJanova

            The keys you are looking up (for each dictionary) are just within one registry node, right? Otherwise the above advice is correct, you should use a control with tree capabilities. A list of dictionaries is probably appropriate. You can only have one set of controls, and switch their data sources when the profile changes.

            T Offline
            T Offline
            TheBlindWatchmaker
            wrote on last edited by
            #5

            BobJanova wrote:

            The keys you are looking up (for each dictionary) are just within one registry node, right? Otherwise the above advice is correct, you should use a control with tree capabilities.

            Yes, they are.

            BobJanova wrote:

            A list of dictionaries is probably appropriate.
             
            You can only have one set of controls, and switch their data sources when the profile changes.

            Thank you! I will look into the list of dictionaries.

            1 Reply Last reply
            0
            • B BobJanova

              The keys you are looking up (for each dictionary) are just within one registry node, right? Otherwise the above advice is correct, you should use a control with tree capabilities. A list of dictionaries is probably appropriate. You can only have one set of controls, and switch their data sources when the profile changes.

              T Offline
              T Offline
              TheBlindWatchmaker
              wrote on last edited by
              #6

              Hi Bob, I have a follow-up question. Is there a way for me to avoid declaring 10 * 7 = 70 dictionaries? 10 is the number of use-cases and 7 is the number of dictionaries I would require for each use case. I have a group of radio controls (gb_profiles) on the GUI and have been able to edit its CheckedChanged function to derive the index of the control that has been checked.

              private void rb_prof_CheckedChanged(object sender, EventArgs e)
              {
              /* We are doing the following here:
              * 1. Identifying the radio button selected
              * 2. Setting the profile_selected variable using the radio button index
              */

                      foreach (Control ctl in gb\_profiles.Controls) 
                      {
                          if (sender.Equals(ctl))
                          {
                              profile\_selected = gb\_profiles.Controls.IndexOf(ctl);
                          }
                      }
                   }
              

              How do I use this to load the dictionary with only the values for this profile? Thanks for your help!

              B 1 Reply Last reply
              0
              • T TheBlindWatchmaker

                Hi Bob, I have a follow-up question. Is there a way for me to avoid declaring 10 * 7 = 70 dictionaries? 10 is the number of use-cases and 7 is the number of dictionaries I would require for each use case. I have a group of radio controls (gb_profiles) on the GUI and have been able to edit its CheckedChanged function to derive the index of the control that has been checked.

                private void rb_prof_CheckedChanged(object sender, EventArgs e)
                {
                /* We are doing the following here:
                * 1. Identifying the radio button selected
                * 2. Setting the profile_selected variable using the radio button index
                */

                        foreach (Control ctl in gb\_profiles.Controls) 
                        {
                            if (sender.Equals(ctl))
                            {
                                profile\_selected = gb\_profiles.Controls.IndexOf(ctl);
                            }
                        }
                     }
                

                How do I use this to load the dictionary with only the values for this profile? Thanks for your help!

                B Offline
                B Offline
                BobJanova
                wrote on last edited by
                #7

                Would you ever have more than one use case open at once? If so, I don't see how you can avoid declaring dictionaries for each use case, and within each one you would have a dictionary for each option. (You could do some lazy loading and caching but honestly for a reasonable sized registry key it is nit worth it.)

                T 1 Reply Last reply
                0
                • B BobJanova

                  Would you ever have more than one use case open at once? If so, I don't see how you can avoid declaring dictionaries for each use case, and within each one you would have a dictionary for each option. (You could do some lazy loading and caching but honestly for a reasonable sized registry key it is nit worth it.)

                  T Offline
                  T Offline
                  TheBlindWatchmaker
                  wrote on last edited by
                  #8

                  I will not be displaying more than one use case at once. However, the user will have the option to save the results of the registry key to a file (I think I am going to go with XML for that). Given this, it appears that I might have to declare dictionaries for all these use cases...

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups