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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. NumericUpDown that updates as you type

NumericUpDown that updates as you type

Scheduled Pinned Locked Moved Visual Basic
winformshelpquestionannouncement
4 Posts 2 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.
  • F Offline
    F Offline
    frobozzdamad
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • F frobozzdamad

      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.

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      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)

      F 1 Reply Last reply
      0
      • M Marcus J Smith

        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)

        F Offline
        F Offline
        frobozzdamad
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • F frobozzdamad

          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.

          M Offline
          M Offline
          Marcus J Smith
          wrote on last edited by
          #4

          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 If

          I 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)

          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