none
Save and retrieve values without application settings.

    Question

  • Hi,

    I am using Visual Studio 2017 for developing a Windows forms application with Visual Basic. (.NET framework 4.5.2)

    I need to save and retrieve values without any exterior files. What I want to really do is re-arranging and changing the controls of form without saving it to any exterior file. Are there any way to save them entirely inside the application?

    Any help will be highly appreciated! :)

    Thanks!

    Tuesday, March 21, 2017 3:37 PM

Answers

  • No, not really, as long as you don't change your definition of "inside" and "exterior".

    But depending you used controls, you can use the user hive of the registry or the %appdata%. Maybe %programdata% is an option, but here you need to evaluate the needed NTFS permissions..

    • Marked as answer by Sithija A Tuesday, March 21, 2017 3:49 PM
    • Unmarked as answer by Sithija A Tuesday, March 21, 2017 3:58 PM
    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 3:40 PM
  • I need to save and retrieve values without any exterior files.

    Then where would it be saved to?

    Your program is strictly read-only once it's compiled.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 3:47 PM
  • Are there any way to permanently change the control positions in code?

    (It too will solve my problem.)

    I don't know who you're talking to - we don't all see this forum the same way - but once it's compiled then it's read-only.

    If you set up a control at design time, then sure because the setting will be part of the designer file (a partial class of the form's class), but once it's compiled then no.

    *****

    Why are you opposed to using an external file? It doesn't have to be Application Settings, there are other ways.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 4:03 PM
  • I am using Visual Studio 2017 for developing a Windows forms application with Visual Basic. (.NET framework 4.5.2)

    I need to save and retrieve values without any exterior files. What I want to really do is re-arranging and changing the controls of form without saving it to any exterior file. Are there any way to save them entirely inside the application?

    If you want to save windows/controls positons/sizes, the standard way is to use the APIs GetWindowPlacement()-SetWindowPlacement() and save data (WINDOWPLACEMENT) in the registry (HKEY_CURRENT_USER)
    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 4:21 PM
  •  I am not so sure why you don`t want to use the Application Settings.  No mater what you do,  the data would have to be saved to a file of some sort and to be honest,  the Registry is not a great place to keep the Locations,  Sizes,  Colors,  Text,  and what not for all the controls.

     If you reconsider using the Application Settings which is meant for things like this,  you can bind each of the control`s properties that you want saved as shown in the animated gif image below.  This shows how to set the BackColor property up with a Setting name but,  can be done with any control.

     You can do this for as many of the controls properties as you need.  After you are done setting these for each of your controls,  you no longer have to do anything else in your code to save or load the settings,  they will be saved automatically when your app is closed and re-loaded and set automatically when your app is run again.

     


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, March 21, 2017 9:02 PM
    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:43 AM
    Tuesday, March 21, 2017 8:59 PM

All replies

  • No, not really, as long as you don't change your definition of "inside" and "exterior".

    But depending you used controls, you can use the user hive of the registry or the %appdata%. Maybe %programdata% is an option, but here you need to evaluate the needed NTFS permissions..

    • Marked as answer by Sithija A Tuesday, March 21, 2017 3:49 PM
    • Unmarked as answer by Sithija A Tuesday, March 21, 2017 3:58 PM
    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 3:40 PM
  • I need to save and retrieve values without any exterior files.

    Then where would it be saved to?

    Your program is strictly read-only once it's compiled.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 3:47 PM
  • Thanks for the answer! I will try to do it.

    Tuesday, March 21, 2017 3:50 PM
  • Thanks for the answer! I will try to do it.

    I thought you said it couldn't be an exterior file?

    I presume that you know that the registry is part of the file system, right?

    http://www.thewindowsclub.com/where-are-the-windows-registry-files-located-in-windows-7


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, March 21, 2017 3:53 PM
  • Or are there any way to permanently change the control positions in code?

    Tuesday, March 21, 2017 3:57 PM
  • Are there any way to permanently change the control positions in code?

    (It too will solve my problem.)

    • Edited by Sithija A Tuesday, March 21, 2017 3:58 PM
    Tuesday, March 21, 2017 3:57 PM
  • Are there any way to permanently change the control positions in code?

    (It too will solve my problem.)

    I don't know who you're talking to - we don't all see this forum the same way - but once it's compiled then it's read-only.

    If you set up a control at design time, then sure because the setting will be part of the designer file (a partial class of the form's class), but once it's compiled then no.

    *****

    Why are you opposed to using an external file? It doesn't have to be Application Settings, there are other ways.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 4:03 PM
  • I am using Visual Studio 2017 for developing a Windows forms application with Visual Basic. (.NET framework 4.5.2)

    I need to save and retrieve values without any exterior files. What I want to really do is re-arranging and changing the controls of form without saving it to any exterior file. Are there any way to save them entirely inside the application?

    If you want to save windows/controls positons/sizes, the standard way is to use the APIs GetWindowPlacement()-SetWindowPlacement() and save data (WINDOWPLACEMENT) in the registry (HKEY_CURRENT_USER)
    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:44 AM
    Tuesday, March 21, 2017 4:21 PM
  •  I am not so sure why you don`t want to use the Application Settings.  No mater what you do,  the data would have to be saved to a file of some sort and to be honest,  the Registry is not a great place to keep the Locations,  Sizes,  Colors,  Text,  and what not for all the controls.

     If you reconsider using the Application Settings which is meant for things like this,  you can bind each of the control`s properties that you want saved as shown in the animated gif image below.  This shows how to set the BackColor property up with a Setting name but,  can be done with any control.

     You can do this for as many of the controls properties as you need.  After you are done setting these for each of your controls,  you no longer have to do anything else in your code to save or load the settings,  they will be saved automatically when your app is closed and re-loaded and set automatically when your app is run again.

     


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, March 21, 2017 9:02 PM
    • Marked as answer by Sithija A Wednesday, March 22, 2017 1:43 AM
    Tuesday, March 21, 2017 8:59 PM