Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Creating application settings at runtime?

Creating application settings at runtime?

Scheduled Pinned Locked Moved C#
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sokka93
    wrote on last edited by
    #1

    Is there a way to create application settings at runtime? So that I can save the locations of each controls on the form. Thanks in advance.

    D H R 3 Replies Last reply
    0
    • S Sokka93

      Is there a way to create application settings at runtime? So that I can save the locations of each controls on the form. Thanks in advance.

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      I'm not sure if you can. What you can do however is create a setting as a List<T> where T is a built in type or a class/struct of your own and add and remove to/from that list. See my article here[^] for examples.

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      1 Reply Last reply
      0
      • S Sokka93

        Is there a way to create application settings at runtime? So that I can save the locations of each controls on the form. Thanks in advance.

        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #3

        Take a look at this[^]. Following the instructions will enable you to save locations, sizes etc. for any control.

        Sokka93 wrote:

        Is there a way to create application settings at runtime

        AFAIK there is no easy way to do this at run-time. However if you follow the link above, it will allow you to do the same thing. Good luck! :)

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        1 Reply Last reply
        0
        • S Sokka93

          Is there a way to create application settings at runtime? So that I can save the locations of each controls on the form. Thanks in advance.

          R Offline
          R Offline
          rick0556
          wrote on last edited by
          #4

          What you could do is create a new registry key Name the new key "Your program settings". RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software,true); ProgSettings.CreateSubKey("Your Program settings"); ProgSettings.Close(); Now you can add Sring Identifiers and values. RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software\\Your Program settings",true) ProgSettings.SetValue("Setting Name",value) //store settings string settings = ProgSettings.GetValue("Setting Name",false);// retreave settings ProgSettings.DeleteValue("Setting Name",Setting Value); Besure to close the registry key when you are done to avoid conflicts with other parts of your program that may write to the registry. Many comercial software applications use these methods. Code Project has many examples about Writing and reading to the registry. This is much easyer the modifying the appconfig.xml file that is used when you create settings. Hope this helps GOD bless Regards

          R 1 Reply Last reply
          0
          • R rick0556

            What you could do is create a new registry key Name the new key "Your program settings". RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software,true); ProgSettings.CreateSubKey("Your Program settings"); ProgSettings.Close(); Now you can add Sring Identifiers and values. RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software\\Your Program settings",true) ProgSettings.SetValue("Setting Name",value) //store settings string settings = ProgSettings.GetValue("Setting Name",false);// retreave settings ProgSettings.DeleteValue("Setting Name",Setting Value); Besure to close the registry key when you are done to avoid conflicts with other parts of your program that may write to the registry. Many comercial software applications use these methods. Code Project has many examples about Writing and reading to the registry. This is much easyer the modifying the appconfig.xml file that is used when you create settings. Hope this helps GOD bless Regards

            R Offline
            R Offline
            rick0556
            wrote on last edited by
            #5

            What you could do is create a new registry key Name the new key "Your program settings". RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software,true); ProgSettings.CreateSubKey("Your Program settings"); ProgSettings.Close(); Now you can add Sring Identifiers and values. RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software\\Your Program settings",true) ProgSettings.SetValue("Setting Name",value) //store settings string settings = ProgSettings.GetValue("Setting Name",false);// retreave settings ProgSettings.DeleteValue("Setting Name",Setting Value); Besure to close the registry key when you are done to avoid conflicts with other parts of your program that may write to the registry. Many comercial software applications use these methods. Code Project has many examples about Writing and reading to the registry. This is much easyer the modifying the appconfig.xml file that is used when you create settings. Hope this helps GOD bless Regards

            S 1 Reply Last reply
            0
            • R rick0556

              What you could do is create a new registry key Name the new key "Your program settings". RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software,true); ProgSettings.CreateSubKey("Your Program settings"); ProgSettings.Close(); Now you can add Sring Identifiers and values. RegistryKey ProgSettings = Registry.CurrentUser.OpenSubKey("Software\\Your Program settings",true) ProgSettings.SetValue("Setting Name",value) //store settings string settings = ProgSettings.GetValue("Setting Name",false);// retreave settings ProgSettings.DeleteValue("Setting Name",Setting Value); Besure to close the registry key when you are done to avoid conflicts with other parts of your program that may write to the registry. Many comercial software applications use these methods. Code Project has many examples about Writing and reading to the registry. This is much easyer the modifying the appconfig.xml file that is used when you create settings. Hope this helps GOD bless Regards

              S Offline
              S Offline
              Sokka93
              wrote on last edited by
              #6

              Thank you very much!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups