Solved

Application and user settings read value in visual studio

Posted on 2014-09-17
8
143 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

726 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