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. C#
  4. NmericUpDown - set the Value outside the range. HELP!!!

NmericUpDown - set the Value outside the range. HELP!!!

Scheduled Pinned Locked Moved C#
questionhelp
11 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.
  • J Offline
    J Offline
    julgri
    wrote on last edited by
    #1

    When I initialize NumericUpDown, how do I set the Value , which is outside the range-it is not allowed by the control. F.x.: NumericUpDown nud=new NumericUpDown(); nud.Min=10; nud.Max=20; nud.Value=30;//this will throw ArgumentOutOfRangeExaption !!!, but I want to allow this assignment and cancel or ignore the exaption Is there any way to do that? I also need the Min and Max to be set, so the user knows the bounds.

    G A 2 Replies Last reply
    0
    • J julgri

      When I initialize NumericUpDown, how do I set the Value , which is outside the range-it is not allowed by the control. F.x.: NumericUpDown nud=new NumericUpDown(); nud.Min=10; nud.Max=20; nud.Value=30;//this will throw ArgumentOutOfRangeExaption !!!, but I want to allow this assignment and cancel or ignore the exaption Is there any way to do that? I also need the Min and Max to be set, so the user knows the bounds.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The control won't let you set the value outside the bounds. You can catch the exception and ignore it, if you like, but that hardly serves any purpose, as the value still won't be set. What is the reason that you want to set the value outside the bounds?

      --- single minded; short sighted; long gone;

      J 2 Replies Last reply
      0
      • G Guffa

        The control won't let you set the value outside the bounds. You can catch the exception and ignore it, if you like, but that hardly serves any purpose, as the value still won't be set. What is the reason that you want to set the value outside the bounds?

        --- single minded; short sighted; long gone;

        J Offline
        J Offline
        julgri
        wrote on last edited by
        #3

        It is not my idea :) But I was asked to do it. Maybe there is the way to cancel the check of the bounds performed by the control, somehow ?

        D 1 Reply Last reply
        0
        • J julgri

          It is not my idea :) But I was asked to do it. Maybe there is the way to cancel the check of the bounds performed by the control, somehow ?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Nope. There's no way to get the value outside the bounds, unless you increase. the Max bound. You'd have to create your own version of the control to get any additional functionality. So, say you ARE successful at getting the value outside the bounds. Why 30? What is supposed to happen when the user types a value into the text box? What if he/she clicks on the Up and Down buttons? If the value supposed to shoot down into the valid range? If you need some kind of flag denoted by the value 30, why not just replace that with a checkbox? If the box is checked, the numeric control gets disabled and a flag is set. If not, the numeric is re-enabled and the flag is reset.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          J 1 Reply Last reply
          0
          • G Guffa

            The control won't let you set the value outside the bounds. You can catch the exception and ignore it, if you like, but that hardly serves any purpose, as the value still won't be set. What is the reason that you want to set the value outside the bounds?

            --- single minded; short sighted; long gone;

            J Offline
            J Offline
            julgri
            wrote on last edited by
            #5

            Maybe I can unsubscribe from the eventhandler that checkes this Value? Is it possible? Just I do not know which event is handling this, but I have a feeling that I know the function, which handles this. Any ideas?

            D 1 Reply Last reply
            0
            • J julgri

              Maybe I can unsubscribe from the eventhandler that checkes this Value? Is it possible? Just I do not know which event is handling this, but I have a feeling that I know the function, which handles this. Any ideas?

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              You never subscribed to one in the first place, so no, you can't unsubscribe from it. Also, this isn't done by an event handler. The check is done inside the Value, Minimum, and Maximum properties. No events are fired to trigger this check.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              J 1 Reply Last reply
              0
              • D Dave Kreskowiak

                Nope. There's no way to get the value outside the bounds, unless you increase. the Max bound. You'd have to create your own version of the control to get any additional functionality. So, say you ARE successful at getting the value outside the bounds. Why 30? What is supposed to happen when the user types a value into the text box? What if he/she clicks on the Up and Down buttons? If the value supposed to shoot down into the valid range? If you need some kind of flag denoted by the value 30, why not just replace that with a checkbox? If the box is checked, the numeric control gets disabled and a flag is set. If not, the numeric is re-enabled and the flag is reset.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                J Offline
                J Offline
                julgri
                wrote on last edited by
                #7

                I know, I know :) All these thought were the first things that came to my mind when I've got this assignment, but for some reason they whant it to be done this way. Eventually, offcourse, we will do it as you are saying, but first I have to proove that it is not possible to impliment it the way they want :) So, any ideas on the stated problem?

                D 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  You never subscribed to one in the first place, so no, you can't unsubscribe from it. Also, this isn't done by an event handler. The check is done inside the Value, Minimum, and Maximum properties. No events are fired to trigger this check.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007

                  J Offline
                  J Offline
                  julgri
                  wrote on last edited by
                  #8

                  Are you sure? If it is so, than there is really no way around it. Good ! :) How do you know that? I could not find such a precise description anywhere.

                  D 1 Reply Last reply
                  0
                  • J julgri

                    Are you sure? If it is so, than there is really no way around it. Good ! :) How do you know that? I could not find such a precise description anywhere.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    Go get Lutz Roeder's .NET Reflector and look at the code in the NumericUpDown class yourself!

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007

                    1 Reply Last reply
                    0
                    • J julgri

                      I know, I know :) All these thought were the first things that came to my mind when I've got this assignment, but for some reason they whant it to be done this way. Eventually, offcourse, we will do it as you are saying, but first I have to proove that it is not possible to impliment it the way they want :) So, any ideas on the stated problem?

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #10

                      julgri wrote:

                      but for some reason they whant it to be done this way.

                      Managers... can't live with 'em, can't shoot 'em.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007

                      1 Reply Last reply
                      0
                      • J julgri

                        When I initialize NumericUpDown, how do I set the Value , which is outside the range-it is not allowed by the control. F.x.: NumericUpDown nud=new NumericUpDown(); nud.Min=10; nud.Max=20; nud.Value=30;//this will throw ArgumentOutOfRangeExaption !!!, but I want to allow this assignment and cancel or ignore the exaption Is there any way to do that? I also need the Min and Max to be set, so the user knows the bounds.

                        A Offline
                        A Offline
                        AikinX
                        wrote on last edited by
                        #11

                        julgri wrote:

                        Is there any way to do that?

                        You can inherit this class to realize this feature for derived class.

                        julgri wrote:

                        I also need the Min and Max to be set, so the user knows the bounds.

                        How a user can understand the Min and Max when he CAN input more or less?

                        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