Movatterモバイル変換


[0]ホーム

URL:


Wayback Machine
17 captures
14 Dec 2007 - 25 Dec 2013
NovDECJul
Previous capture29Next capture
201020112013
success
fail
COLLECTED BY
Organization:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
Collection:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20111229181823/http://www.codeproject.com:80/KB/edit/HDNumericTextBox.aspx
Click here to Skip to main content
8,370,895 members and growing!
EmailPassword Lost password?
Home
Search within:




Licence 
First Posted 20 Jun 2004
Views 215,197
Downloads 1,802
Bookmarked 53 times

Numeric TextBox : Allow your users to enter numeric data the easy way

ByHannes Decorte | 20 Jun 2004
A TextBox control for numeric input, with the ability to set precision, scale (when focused or not)
 
See Also
Print Article
add
Add to your CodeProject bookmarks
Discuss
Discuss this article
40
  4.36 (22 votes)
3 votes, 13.6%
1
1 vote, 4.5%
2
3 votes, 13.6%
3
5 votes, 22.7%
4
10 votes, 45.5%
5
4.36/5 - 22 votes
3 removed
μ 3.90, σa 2.51 [?]
Sponsored Links

Introduction

Numeric input has always been one of the key-features in many applications (CRM, Accounting,...). Although MS provides a masked edit control, many developers find it to have some limitations.

The Numeric TextBox tries to provide some features to allow the user to input numeric data in a natural way. Let's have a look at some of the key features.

  1. Allow/Disallow negative input.
  2. Specify the maximum precision and scale.
  3. Specify a different scale when the control hasn't got the focus.
  4. Allow/Disallow zero as a valid input.
  5. The control displays grouping characters.
  6. The control adapts the regional settings (grouping char, decimal char).

Using the code

To use the control simply reference theShorty.Windows.Forms assembly in your project. Create (or drag and drop on the form) aNumericTextBox and set the properties. The properties can be set trough code or via the property pane (Numeric settings section). See below for an example.

//// numericTextBox1//Shorty.Windows.Forms.NumericTextBox() numericTextBox1 =new Shorty.Windows.Forms.NumericTextBox();this.numericTextBox1.AllowNegative =true;this.numericTextBox1.DataBindings.Add(new System.Windows.Forms.Binding("NumericValue",this,"Table1.test"));this.numericTextBox1.NumericPrecision =8;this.numericTextBox1.NumericScaleOnFocus =5;this.numericTextBox1.NumericScaleOnLostFocus =3;this.numericTextBox1.NumericValue =0;this.numericTextBox1.ZeroIsValid =false;

The control automatically checks if the combinationNumericPrecision NumericScaleOn(Lost)Focus is valid. As you can see in the above sample to retrieve the numeric value displayed in theNumericTextBox you should use theNumericValue property.The control is also capable of databinding it'sNumericValue property. (See above code sample).

History

  • Initial release version 0.1.0.0 (20/06/2004)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be foundhere

About the Author

Hannes Decorte

Web Developer

Belgium Belgium

Member
3 years ago I started out with VB 6 and ASP. After seeing .Net in Beta in 2001 I haven't done anything else. I moved from VB6 over VB.Net to C#.
In 2004 I earned my MCAD. Currently I am employed as a Analyst/Developer and I'm working towards my MCDBA (1 exam to goSmile | :) ).
 
You can follow me at my blog http://radio.weblogs.com/0132279/

loading...
Sign Up to vote  PoorExcellent
Add a reason or comment to your vote:x
Votes of 3 or less require a comment

Comments and Discussions

 
 RefreshFirstPrevNext
BugI can't place it on a form... helpmemberIApple0:29 16 Sep '11  
GeneralRe: I can't place it on a form... helpmemberMember 825996521:34 1 Oct '11  
GeneralRe: I can't place it on a form... helpmemberTassosK6:19 19 Oct '11  
GeneralThanxmemberBeni Sec8:18 10 Nov '10  
QuestionPlease help...memberdynaduo13:45 16 Sep '10  
GeneralBUGmemberLimitedAtonement8:11 2 Nov '09  
Generalfailed to create componentmembersari5sundar4:02 15 May '09  
GeneralThis methods work toomembersyedmasroorahmed20:27 29 Apr '09  
GeneralFailed to create component...memberJulius9115:40 25 Mar '09  
GeneralRe: Failed to create component...memberJulius9117:12 27 Mar '09  
Last Visit: 19:00 31 Dec '99     Last Update: 8:18 29 Dec '111234Next »

General General   News News   Suggestion Suggestion   Question Question   Bug Bug   Answer Answer   Joke Joke   Rant Rant   Admin Admin   

Permalink |Advertise |Privacy |Mobile
Web03 |2.5.111208.1 |Last Updated 21 Jun 2004
Article Copyright 2004 by Hannes Decorte
Everything elseCopyright ©CodeProject, 1999-2011
Terms of Use
Layout:fixed|fluid

See Also...
The Daily Insider

[8]ページ先頭

©2009-2025 Movatter.jp