Solved

Application and user settings read value in visual studio

Posted on 2014-09-17
8
140 Views
Last Modified: 2014-11-27
Hi EE,

    I want to change our current way of reading application setting from a text file on disk to have those settings stored in app.config file.
   
   I wrote a class 'TXSettings' which has 100 properties that I'm intending to use to get all the application settings.
 
   I call a 'Load' method upon project startup

 Public Shared Function Load1() As TXSettings

        Dim settings As New TXSettings
        With settings
            .SpeedUnit = My.Settings.SpeedUnit
            .UpgradeRequired = My.Settings.UpgradeRequired
            ......   'The next 98 properties
        End With
        Return settings
    End Function

Open in new window


as you can see the load method will have something like above, is there a cleaner way of doing this? like a loop thru or something else?
0
Comment
Question by:miketonny
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:Akilandeshwari N
ID: 40329581
0
 
LVL 2

Author Comment

by:miketonny
ID: 40329587
hi @Akilandeshwari N,

   how do you do this with an object class? I know System.Reflection and loop through all properties in a class but I don't want to use reflection
0
 
LVL 40
ID: 40329595
Why should you use a custom class to get the settings? My.Settings is already a class that does it for you.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 2

Author Comment

by:miketonny
ID: 40329625
@JamesBurger,
I haven't tried, but can i bind the datacontext of a window to my.settings?

my planning is to create a 'setting' window for user to view and edit the current setting of the application, with wpf databinding to a class that's real easy.

or is this the correct way of doing this?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40329714
I could not say in WPF, my expertise is in Windows Forms Applications. In that environment, yes, you can bind controls to My.Settings just as you can with almost any class in the application.
0
 
LVL 2

Author Comment

by:miketonny
ID: 40329962
thank you for your suggestion
I've found some resources on google showing me  how to bind settings in wpf, gonna try it tomorrow
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question