Originally posted by: diegoalcatraz
I suppose you could just listen for the KeyPress events, and then filter those so you respond to the Enter key?
Originally posted by: oog
What event do you want it to throw? Your own? You have control over when you throw your events.
Originally posted by: diegoalcatraz
If this is for what I think it is (Axel) then ... what I did was listen for the text change event, and attempted to validate the contents of the text box (make sure they're numbers). int.Parse works. If that passes, I use that int value to set the counter. If the parse fails, then they entered invalid characters, so I rollback to a previous value.
Originally posted by: oog
I don't think there is support for a filter on when the event should be fired. The keypress will fire with each keypress. You can put in an if statement to test for the Enter key and filter the input yourself. Alternately, you could subclass the textbox and expose an event that is only fired if the Enter key is pressed.
Originally posted by: Jumpem
Originally posted by: diegoalcatraz
If this is for what I think it is (Axel) then ... what I did was listen for the text change event, and attempted to validate the contents of the text box (make sure they're numbers). int.Parse works. If that passes, I use that int value to set the counter. If the parse fails, then they entered invalid characters, so I rollback to a previous value.
Yes it is for Axel's class. :shocked:
I tried to use the text change event, but it gets triggered as soon as they enter one digit, say "4". But we don't want it to trigger until an entire number is entered, such as "435".
You can answer here or email me at jmm0257@cs.rit.edu.
Thanks! - Justin
Originally posted by: diegoalcatraz
If this is for what I think it is (Axel) then ... what I did was listen for the text change event, and attempted to validate the contents of the text box (make sure they're numbers). int.Parse works. If that passes, I use that int value to set the counter. If the parse fails, then they entered invalid characters, so I rollback to a previous value.
