NmericUpDown - set the Value outside the range. HELP!!!
-
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.
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;
-
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;
-
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 ?
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 -
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;
-
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?
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 -
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, 2007I 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?
-
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 -
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.
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 -
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?
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 -
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.
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?