How do you restrict textBox entry?
-
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
-
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
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
-
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
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
-
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
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
-
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
-
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
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:
-
Fine Mike, you win. I wont bother picking your brain anymore. I dont understand why you insist on being such an asshole.
-
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