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 to refuse changes of controls in a form ?

How to refuse changes of controls in a form ?

Scheduled Pinned Locked Moved C#
tutorialquestion
7 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.
  • T Offline
    T Offline
    taibc
    wrote on last edited by
    #1

    Hi friends, Are there any methods to refuse changes of controls in a form ? For example: I have a form that include one text box: txtNumber, and one Exit button. At the first time, txtNumber.Text = "30" (When showing form) Then, I changed the its value into "45". After that, I don't want to accept changes, I clicked the Exit button. Then txtNumber.Text is still "45". I want this value is "30". Are there any method to refuse changes of TextBox in this case ? Thanks and regards,

    P E F 3 Replies Last reply
    0
    • T taibc

      Hi friends, Are there any methods to refuse changes of controls in a form ? For example: I have a form that include one text box: txtNumber, and one Exit button. At the first time, txtNumber.Text = "30" (When showing form) Then, I changed the its value into "45". After that, I don't want to accept changes, I clicked the Exit button. Then txtNumber.Text is still "45". I want this value is "30". Are there any method to refuse changes of TextBox in this case ? Thanks and regards,

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Simply set the ReadOnly property to true to prevent anybody from being able to change it via the UI.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      T 1 Reply Last reply
      0
      • P Pete OHanlon

        Simply set the ReadOnly property to true to prevent anybody from being able to change it via the UI.

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        T Offline
        T Offline
        taibc
        wrote on last edited by
        #3

        allow to change (not Readonly)

        1 Reply Last reply
        0
        • T taibc

          Hi friends, Are there any methods to refuse changes of controls in a form ? For example: I have a form that include one text box: txtNumber, and one Exit button. At the first time, txtNumber.Text = "30" (When showing form) Then, I changed the its value into "45". After that, I don't want to accept changes, I clicked the Exit button. Then txtNumber.Text is still "45". I want this value is "30". Are there any method to refuse changes of TextBox in this case ? Thanks and regards,

          E Offline
          E Offline
          Ed Hill _5_
          wrote on last edited by
          #4

          Are you meaning that you want to be able to either commit the changes if a "save/Commit" button is pressed, and undo changes if the exit button is pressed? If that is the case, your exit button could simply trigger the method you used to set the values when showing the form.

          T 1 Reply Last reply
          0
          • E Ed Hill _5_

            Are you meaning that you want to be able to either commit the changes if a "save/Commit" button is pressed, and undo changes if the exit button is pressed? If that is the case, your exit button could simply trigger the method you used to set the values when showing the form.

            T Offline
            T Offline
            taibc
            wrote on last edited by
            #5

            Thanks Ed Hill_5_, That is my mean, I will try it

            P 1 Reply Last reply
            0
            • T taibc

              Thanks Ed Hill_5_, That is my mean, I will try it

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Please, in future, try to be clearer with your questions. There is no way, from your original post, that I would have been able to guess what your question actually was.

              *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

              "Mind bleach! Send me mind bleach!" - Nagy Vilmos

              CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

              1 Reply Last reply
              0
              • T taibc

                Hi friends, Are there any methods to refuse changes of controls in a form ? For example: I have a form that include one text box: txtNumber, and one Exit button. At the first time, txtNumber.Text = "30" (When showing form) Then, I changed the its value into "45". After that, I don't want to accept changes, I clicked the Exit button. Then txtNumber.Text is still "45". I want this value is "30". Are there any method to refuse changes of TextBox in this case ? Thanks and regards,

                F Offline
                F Offline
                Fred 34
                wrote on last edited by
                #7

                simply save the pre value and return it in case of pressing exit buttom.

                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