locked
my.settings won't let me access my settings

    Question

  • Using VS 2005 and .NET 2, I'm creating a Visual Basic windows form and trying to work with user settings.  So, I add a new item to the project, select a settings file, then add a user setting (ex: customtext) via the settings designer. 


    Back in my VB app, if I try to do something such as:

    textbox1.text = my.settings.customtext

    it will tell me that customtext is not a member of my.settings, even though if I go into the settings designer, it's right there as a string with a value of "test".

    I've been scouring webpages for at least a couple of hours to no avail.  Any ideas?
    Friday, April 25, 2008 1:42 AM

Answers

  • What is the name of the settings file?  You would refer to it using

     

    textbox1.text = (SettingsFile).Default.customtext.

     

    For instanace, if your settings file was called MySettingsFile, it would be MySettingsFile.Default.customtext.

     

    Hope this helps.

     

    Friday, April 25, 2008 1:51 AM

All replies

  • What is the name of the settings file?  You would refer to it using

     

    textbox1.text = (SettingsFile).Default.customtext.

     

    For instanace, if your settings file was called MySettingsFile, it would be MySettingsFile.Default.customtext.

     

    Hope this helps.

     

    Friday, April 25, 2008 1:51 AM
  • This worked, but I'm very confused.  I must have read a million code samples where people are using my.settings so I don't understand what's different about my environment.  I will come back and figure that out later, I guess.  Thanks for your help!
    Friday, April 25, 2008 6:40 PM
  • Hi Technonaut2050,

    Read Using My.Settings about this issue. Because this value will be saved in the App.config file(or use.config), I think that you don't need to add some setting files in this scenario.

    Best regards,
    Riquel
    Tuesday, April 29, 2008 6:23 AM