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. Managed C++/CLI
  4. How do you restrict textBox entry?

How do you restrict textBox entry?

Scheduled Pinned Locked Moved Managed C++/CLI
questioncsharpc++visual-studio
9 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.
  • B Offline
    B Offline
    BuckBrown
    wrote on last edited by
    #1

    Hi, I'm using Visual Studio 2005 C++/CLI. This should be an easy one. I have a textBox that has some number in it. When I press the (+) or (-) key on the far right keypad I can use ::Keys::Add and Keys::Subtract to recognize that those keys had been pressed and I can increment and decrement the number, and then put number.ToString() back in the textBox but the "+" or "-" character gets added to the textBox (and I don't want that). How do I restrict the characters that can be added to a textBox->Text String^? Thanks, Buck

    L 1 Reply Last reply
    0
    • B BuckBrown

      Hi, I'm using Visual Studio 2005 C++/CLI. This should be an easy one. I have a textBox that has some number in it. When I press the (+) or (-) key on the far right keypad I can use ::Keys::Add and Keys::Subtract to recognize that those keys had been pressed and I can increment and decrement the number, and then put number.ToString() back in the textBox but the "+" or "-" character gets added to the textBox (and I don't want that). How do I restrict the characters that can be added to a textBox->Text String^? Thanks, Buck

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      So you are still trying to develop software without reading the documentation eh? How is that working so far? :rolleyes: To restrict text from being entered in a TextBox control, you can create an event handler for the KeyDown event in order to validate each character entered in the control. http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.aspx[^]

      led mike

      B 1 Reply Last reply
      0
      • L led mike

        So you are still trying to develop software without reading the documentation eh? How is that working so far? :rolleyes: To restrict text from being entered in a TextBox control, you can create an event handler for the KeyDown event in order to validate each character entered in the control. http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.aspx[^]

        led mike

        B Offline
        B Offline
        BuckBrown
        wrote on last edited by
        #3

        Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented). Notice how they don't show you how to do it they just tell you to do it. That being aside, I AM using an event handler for when the keys are pressed (that is how I can recognize when the (+) and (-) keys are pressed with Keys::Add and Keys::Subtract), the question is how do you keep it out of the textBox->Text String? I guess I just have to let the character get added to the text string and then search the text string for the character I just typed and then delete it from the string. Buck

        L M 2 Replies Last reply
        0
        • B BuckBrown

          Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented). Notice how they don't show you how to do it they just tell you to do it. That being aside, I AM using an event handler for when the keys are pressed (that is how I can recognize when the (+) and (-) keys are pressed with Keys::Add and Keys::Subtract), the question is how do you keep it out of the textBox->Text String? I guess I just have to let the character get added to the text string and then search the text string for the character I just typed and then delete it from the string. Buck

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          BuckBrown wrote:

          Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented)

          Your kidding right? Who do you write your technical documentation for, used car sales men? So you have produced a better operating system? Give me a link to it and I will try to help you. Or even give me a link to your technical documentation you produced that is better than Microsofts, then I will help you. Ooops, I forgot to check my CodeProject.AVOID list, you are already on it, never mind, my bad.

          led mike

          B K 2 Replies Last reply
          0
          • L led mike

            BuckBrown wrote:

            Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented)

            Your kidding right? Who do you write your technical documentation for, used car sales men? So you have produced a better operating system? Give me a link to it and I will try to help you. Or even give me a link to your technical documentation you produced that is better than Microsofts, then I will help you. Ooops, I forgot to check my CodeProject.AVOID list, you are already on it, never mind, my bad.

            led mike

            B Offline
            B Offline
            BuckBrown
            wrote on last edited by
            #5

            Fine Mike, you win. I wont bother picking your brain anymore. I dont understand why you insist on being such an asshole.

            L 1 Reply Last reply
            0
            • B BuckBrown

              Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented). Notice how they don't show you how to do it they just tell you to do it. That being aside, I AM using an event handler for when the keys are pressed (that is how I can recognize when the (+) and (-) keys are pressed with Keys::Add and Keys::Subtract), the question is how do you keep it out of the textBox->Text String? I guess I just have to let the character get added to the text string and then search the text string for the character I just typed and then delete it from the string. Buck

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              BuckBrown wrote:

              question is how do you keep it out of the textBox->Text String?

              Does the sample code here do what you want? KeyPressEventArgs::Handled Property[^]

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              1 Reply Last reply
              0
              • B BuckBrown

                Fine Mike, you win. I wont bother picking your brain anymore. I dont understand why you insist on being such an asshole.

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                BuckBrown wrote:

                (worst operating system ever invented)

                Yeah, I'm sure you're right though, I'm the asshole. :rolleyes:

                led mike

                1 Reply Last reply
                0
                • L led mike

                  BuckBrown wrote:

                  Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented)

                  Your kidding right? Who do you write your technical documentation for, used car sales men? So you have produced a better operating system? Give me a link to it and I will try to help you. Or even give me a link to your technical documentation you produced that is better than Microsofts, then I will help you. Ooops, I forgot to check my CodeProject.AVOID list, you are already on it, never mind, my bad.

                  led mike

                  K Offline
                  K Offline
                  killabyte
                  wrote on last edited by
                  #8

                  how in gods name did you get to be an MVP?

                  L 1 Reply Last reply
                  0
                  • K killabyte

                    how in gods name did you get to be an MVP?

                    L Offline
                    L Offline
                    led mike
                    wrote on last edited by
                    #9

                    fuck off asshole, go back to the soapbox

                    led mike

                    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