NumericUpDown that updates as you type
-
Hello, is there any way to get a NumericUpDown control to update and validate itself as you type? My problem is: The NUD control updates it's Value property when you use the up-down arrows, but it doesn't update itself as you type until it has lost focus. What I am trying to do is have a "FINISHED" button stay Enabled=False until the value entered into the NUD control is greater than a certain amount, then, I want it to Enabled=True. I don't want the user to have to click off the NUD control or have to "Tab" off if it just to throw a LostFocus event just for the "finished" button to light up. Can this be done? Are there any already written user controls or chunks of code out there that already do this? Thanks.
-
Hello, is there any way to get a NumericUpDown control to update and validate itself as you type? My problem is: The NUD control updates it's Value property when you use the up-down arrows, but it doesn't update itself as you type until it has lost focus. What I am trying to do is have a "FINISHED" button stay Enabled=False until the value entered into the NUD control is greater than a certain amount, then, I want it to Enabled=True. I don't want the user to have to click off the NUD control or have to "Tab" off if it just to throw a LostFocus event just for the "finished" button to light up. Can this be done? Are there any already written user controls or chunks of code out there that already do this? Thanks.
It is ALOT of events but look at using the KeyPress/KeyUp/KeyDown (whichever works best) events for that control.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
-
It is ALOT of events but look at using the KeyPress/KeyUp/KeyDown (whichever works best) events for that control.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
Well, I gave it a few days of hard effort, but there's just too much going on to trap. Essentially, I had to try to, based on key-presses within the control, figure out it's value at all times. I got it about 80% of the way there with using overrides and such but things like "using the mouse to highlight the box and hitting delete" as opposed to "highlighting a digit or two and hitting delete" made me aware this is way over my head. Once again, I toss this out to the forums: Need a numeric text entry control. Control has to at all times, know it's value, including while entering. Basically, if it's on the screen; it has to know it's value. Does such a beast exist for the .NET framework? Thank you.
-
Well, I gave it a few days of hard effort, but there's just too much going on to trap. Essentially, I had to try to, based on key-presses within the control, figure out it's value at all times. I got it about 80% of the way there with using overrides and such but things like "using the mouse to highlight the box and hitting delete" as opposed to "highlighting a digit or two and hitting delete" made me aware this is way over my head. Once again, I toss this out to the forums: Need a numeric text entry control. Control has to at all times, know it's value, including while entering. Basically, if it's on the screen; it has to know it's value. Does such a beast exist for the .NET framework? Thank you.
Is this for a Windows Form? If so .NET 2.0 brought back the masked text box which can only allow numerics if you set that property but you can also just validate the text after the fact. A better way to do this on your own would be to use the textbox's KeyPress event or something along those lines and look at the following.
If e.KeyChar = Chr(CharCode for 0-9) Then
e.Handled = True
Else
e.Handled = False
End IfI think that is all you really need to do. -- modified at 12:10 Tuesday 29th May, 2007
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)