Solved

Application and user settings read value in visual studio

Posted on 2014-09-17
8
142 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

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.

Question has a verified solution.

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

Okay. So what exactly is the problem here? How often have we come across situations where we need to know if two strings are 'similar' but not necessarily the same? I have, plenty of times. Until recently, I thought any functionality like that wo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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