Skip to content

Need help with NameValueCollection

Jacob R

Asked Feb 15, 2010, 3:49 PM EST3 answers
Share
LinkedInX
I want to save a NameValueCollection that can be used later in my winForm Application.  The thing is,  I want to user to be able to specify the name of the NVC and then it will save each name and value within that user specified NVC.  Then I'll store the name that they gave the NVC into a listBox and if they want to edit anything later, they can just select the name in the listBox and it will show all of the names and values within that NVC. 
I know how to do everything except, allowing the user to name the NVC and I don't know how to have access to it later.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Diptimaya Patra
    0
    Hi,
    You can use app.config to store NVC. Just go to your project properties and you would find "Settings" tab. There you can set your Collection name. I am not sure about Dictionary object but it supports Collection of String, so you can have two collections with names such as Name and Value.
    This is the easiest solution I have experienced.
    Thanks
    Diptimaya Patra
    --------------------------------------------
    MARK IT AS ANSWER IF IT HELPS
    0
  • 0
    Thanks.  I've been reading into it and, what about making a class with a getter to get the NameValueCollection and a setter to set keys and values to it?  The only problem I'm having at the moment is, how do I use the text inside of a textbox to give a name to the class?
    0
  • 0
    I guess my next problem would be, how would I make that object available to the rest of my program?  I name the object and set all of the values within a method but I want to be able to use that object name in another method to show the values.
    0