Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C# Storing Application Settings

  • 14-07-2010 1:56pm
    #1
    Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭


    I'm attempting to store application settings, however I'm having trouble storing/accessing multiple values.

    E.g I want to store a text list of colours for use in a drop-down box, I've edited my app.config to this;
    <setting name="Colours" serializeAs="String">
    <value>Green</value>
    <value>White</value>
    <value>Gold</value>
    </setting>
    

    But
    Properties.Settings1.Default.Colours
    
    will only contain the 1st value - "Green".

    Any ideas? Or is there an easier way to store application settings with multiple values?


Comments

  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    Been a while since I done some .net stuff, but I think you need to serialize your settings as xml and use xml as your value or something along those lines as serializeAs="String" just stores a single value
    <setting name="Colours" serializeAs="XML">
    <value>
    <colorlist>
    <color>Green</color>
    <color>White</color>
    </colorlist>
    </value>
    </setting>
    


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    The problem seems to be that that you have 3 value elements in your setting and you should only have one as you're using serializeAs="string". Have a read of this: http://msdn.microsoft.com/en-us/library/ms229207.aspx which explains the elements. Then you could have a read of: http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx and perhaps roll your own custom settings.

    You may even be able to serialize it as XML and then deserialize the XML as you want it in code.

    <edit>
    lynchie beat me to it
    </edit>


  • Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭CountingCrows


    Muchas gracias!

    I'll test it out in the morning.


Advertisement