473,769 Members | 7,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

numeric up-downs and enforcing the range

I just noticed that a numeric up/down will let you manually type in any
number even if it is beyond the min/max range you specified.
The control will not actually return this value if it is beyond the min/max
but it won't give you any indication that the value you typed in is out of
range.
Any way to get around this so a user typing in a number out of range will
get some kind of warning ?
Nov 16 '05 #1
2 1917
Trap it in the Validating event or do range checking when the value changes
and set it back to something sensible.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"MrNobody" <Mr******@discu ssions.microsof t.com> wrote in message
news:1A******** *************** ***********@mic rosoft.com...
I just noticed that a numeric up/down will let you manually type in any
number even if it is beyond the min/max range you specified.
The control will not actually return this value if it is beyond the
min/max
but it won't give you any indication that the value you typed in is out of
range.
Any way to get around this so a user typing in a number out of range will
get some kind of warning ?

Nov 16 '05 #2
That's odd, I set an onValidating event and was going to do a range check on
the value and do whatever fix necessary when I realized once I set the event
and called Value property on the numeric up down, it automatically changes
the text to fit in the range... so my event just looks like this:

private void onValidatingUpD own(object sender,
System.Componen tModel.CancelEv entArgs e) {

NumericUpDown control = sender as NumericUpDown;
decimal value = control.Value;
}

and that's it... guess the Value property does the range check?

"Bob Powell [MVP]" wrote:
Trap it in the Validating event or do range checking when the value changes
and set it back to something sensible.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"MrNobody" <Mr******@discu ssions.microsof t.com> wrote in message
news:1A******** *************** ***********@mic rosoft.com...
I just noticed that a numeric up/down will let you manually type in any
number even if it is beyond the min/max range you specified.
The control will not actually return this value if it is beyond the
min/max
but it won't give you any indication that the value you typed in is out of
range.
Any way to get around this so a user typing in a number out of range will
get some kind of warning ?


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2504
by: Chris Weisiger | last post by:
I'm trying to install numeric on my MacOS X box using Darwin, with the eventual goal of satisfying all of PyGame's dependencies so I can finally start working on my semester project. I would be using MacPython, except that I can't seem to get its Package Manager to work. Anyway, when I try to install numeric, I get the following error: chriswei% sudo ./setup.py install Password: running install running build
1
1574
by: jelle | last post by:
#No rant intended I'm not at all confused wether I should learn an one of the advanced array modules, I'm slightly confused over which I should pick up. I'm impressed with the efforts of SciPy and Scientific, but since I'm fairly new to programming & OO, choosing Numarray over Numeric hasnt been that satisfactory at all, which is not a problem of the quality of Numarray, but the fact that a lot of modules still heavily realy on Numeric....
4
3955
by: Gezeala 'Eyah' Bacu\361o II | last post by:
hey guys..need your help on this.. i have a plpgsql function where in i compute numeric values for my php scripts.. my problem is my function just won't round some numbers properly.. what i want it to do is like this. example:
7
3943
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34 123.0000 123 i.e. I want to trim trailing zeros and (decimal point if no decimal values
0
1095
by: john_20_28_2000 | last post by:
Does anyone know of anything out there that I can use to dial up a numeric pager, leave a number and then hang up? It is not a "fancy" pager. No message, not text, no nothing. Just a regular old pager. I have looked at the various SMS stuff, but it all goes to text message, etc. Nothing for a regular pager. I have a asp.net page. User clicks a button that says "Page Me." Somehow the box with the modem dials up the pager and leaves the...
15
1903
by: W. Watson | last post by:
For some reason Python 2.2.4 cannot find the Numeric module. It's been suggested that I should re-install the Numeric file. How do that? Also the PIL. The three install files are: python-2.4.4.msi PIL-1.1.5.win32-py2.4.exe Numeric-24.2.win32-py2.4.exe Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
11
2581
by: ZMY | last post by:
Dear all, I am a real newbie for both python and QNX, but I am still trying to compile Numeric-24.2 under QNX4.25 with python 2.2. I got following error message: $ sudo python setup.py install Password: running install
8
9328
by: Frank Swarbrick | last post by:
My DBA says that a column defined, for instance, as DECIMAL(11,2) and containing a value of 1.00 takes up no more space on the database disk than a column defined as DECIMAL(7,2) and containing a value of 1.00. I am honestly having a hard time believing this, but I don't know where I can find the answer. Help? Thanks, Frank
3
20022
by: tdickerson | last post by:
Hi, I'm encountering a strange error after an upgrade has been run on a test site. Attempting to SELECT * FROM table or even just entering SELECT * (no table specified) returns the following error: SQL0103N The numeric literal "1234_upgrade" is not valid. SQLSTATE=42604 The only place that I could see that coming from is the name of the folder the database was backed up to before the upgrade. I did a search within files of the upgrade...
5
1058
by: Benyang | last post by:
Maybe it has been reported somewhere, but it is a big surprise to me. # Try the following: import Numeric a = Numeric.ones(10) a = -1 print a It works correctly on 32-bit linux machines and on 32-bit Windows XP:
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.