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. how do i make the value in text box permanent

how do i make the value in text box permanent

Scheduled Pinned Locked Moved C#
questioncsharphelp
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.
  • V Offline
    V Offline
    VIJAYPAPUPAGER
    wrote on last edited by
    #1

    i am a begineer in c#,and am not getting exact technical terms to explain my problem, though i shall try my best.i have developed a program which takes values from a textbox. its obvious that when i run the program for second time the previously entered values through textbox will get wiped out & textbox will ask for new values. how do i avoid this? how do i make program to run as may times as i want on the values i entered for first time when i ran the program? & only take new values when i change the contents of textbox & continue with this values for any number of times i run the program.

    G H 2 Replies Last reply
    0
    • V VIJAYPAPUPAGER

      i am a begineer in c#,and am not getting exact technical terms to explain my problem, though i shall try my best.i have developed a program which takes values from a textbox. its obvious that when i run the program for second time the previously entered values through textbox will get wiped out & textbox will ask for new values. how do i avoid this? how do i make program to run as may times as i want on the values i entered for first time when i ran the program? & only take new values when i change the contents of textbox & continue with this values for any number of times i run the program.

      G Offline
      G Offline
      Guinness4Strength
      wrote on last edited by
      #2

      You need to write the initially entered value to a file or registry someplace. The most commplace is either an INI file or the Registry.

      H 1 Reply Last reply
      0
      • G Guinness4Strength

        You need to write the initially entered value to a file or registry someplace. The most commplace is either an INI file or the Registry.

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Not for a .NET application. It's recommended you don't use the registry (for deployment reasons), and even more recommended you don't use INI files (the flat structure is very problematic in this day and age).

        Microsoft MVP, Visual C# My Articles

        S 1 Reply Last reply
        0
        • V VIJAYPAPUPAGER

          i am a begineer in c#,and am not getting exact technical terms to explain my problem, though i shall try my best.i have developed a program which takes values from a textbox. its obvious that when i run the program for second time the previously entered values through textbox will get wiped out & textbox will ask for new values. how do i avoid this? how do i make program to run as may times as i want on the values i entered for first time when i ran the program? & only take new values when i change the contents of textbox & continue with this values for any number of times i run the program.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          It's a common practice to actually serialize your controls using XML Serialization to a file. When you instantiate these controls you read your values from that file again. The biggest problem with serialization, though, is that your controls are actually deserialized in their entirety. So the best approach for you is to use an XmlDocument or XmlTextWriter to write these values to an XML file, and read them back in with XmlDocument or XmlTextReader. Using XML files is easy in .NET, and there are actually lots of articles here on CodeProject about just what you're asking. You could use the registry (it's strongly recommended you don't use INI files, which are not supported by the .NET FCL (framework class library)), but it's not recommended for deployment reasons. This isn't always such a bad thing if you don't require initial registry values, though. In your case, that would be true. So whether you use an XML file or the registry, just save your text when the form is closed and read them back in when you open your form.

          Microsoft MVP, Visual C# My Articles

          1 Reply Last reply
          0
          • H Heath Stewart

            Not for a .NET application. It's recommended you don't use the registry (for deployment reasons), and even more recommended you don't use INI files (the flat structure is very problematic in this day and age).

            Microsoft MVP, Visual C# My Articles

            S Offline
            S Offline
            surgeproof
            wrote on last edited by
            #5

            then what *do* you use? ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein

            H 1 Reply Last reply
            0
            • S surgeproof

              then what *do* you use? ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              I posted it as a direct reply to the parent thread. .config files are best to target, although writing to them can be dangerous if you don't take errors into account. The registry is an option, but is not recommended because of deployment issues, such as XCOPY deployment.

              Microsoft MVP, Visual C# My Articles

              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