Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C#

Yet Another Custom Currency Box

Rate me:
Please Sign up or sign in to vote.
2.85/5 (14 votes)
23 May 2009CPOL 54.7K   1.1K   24   14
Control that only allows numeric inputs
Sample Image - CurrencyBox.gif

Introduction

Trying to make my first custom control, I decided to build a textbox that will only allow numeric inputs. So I searched on the internet and found a very good control (NumericBox). I try to reproduce it to include it in my new personal custom controls library.

Help

  1. Use "," or "." to put the cursor before or after a decimal separator.
  2. "-" if enabled negative numbers add a minus sign.
  3. "+" Convert negative number to positive.
  4. BackSpace, erase the integer part of the number.
  5. Del, erase the decimal part of the number.

Thanks to

  • ProSoft for the great idea

Update

  • 24/05/2009: Enhancement
    • Added MaxValue and MinValue properties
    • Added ShowThousand separator property
  • 28/01/2007: Fixed Bugs
    • Deleting a number with backspace, the control eliminates two numbers

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Spain Spain
Graduado de Ingenieria Mecánica en la Cujae (2001),
Universidad de la Habana, Cuba

Comments and Discussions

 
QuestionSelect text on got focus event Pin
MCAST7610-Dec-11 5:42
MCAST7610-Dec-11 5:42 
GeneralI have Convert this Code Into VB but it doesn't work can u help me??? Pin
SunLucDong16-Apr-11 21:13
SunLucDong16-Apr-11 21:13 
GeneralHindi Numbers Pin
PeaceTiger6-Nov-10 10:22
PeaceTiger6-Nov-10 10:22 
GeneralRe: Hindi Numbers Pin
PeaceTiger6-Dec-10 21:03
PeaceTiger6-Dec-10 21:03 
GeneralMy vote of 5 Pin
PeaceTiger15-Oct-10 15:25
PeaceTiger15-Oct-10 15:25 
GeneralNice control but i experienced some weird issues Pin
Member 25738317-Jan-10 6:35
Member 25738317-Jan-10 6:35 
GeneralMnemonics issue Pin
Eric Marin15-Oct-09 5:02
Eric Marin15-Oct-09 5:02 
GeneralPocket PC project Pin
PGuimaraes3-Sep-08 4:07
PGuimaraes3-Sep-08 4:07 
GeneralThanks Pin
DALAS_<><>14-Jun-07 23:11
DALAS_<><>14-Jun-07 23:11 
GeneralChange to to control Pin
hardsoft14-Jun-07 9:54
hardsoft14-Jun-07 9:54 
GeneralBut it's in C# Code not C++ Pin
Nacereddine29-Jan-07 1:20
professionalNacereddine29-Jan-07 1:20 
GeneralThank you! Pin
MCAST7626-Jan-07 7:12
MCAST7626-Jan-07 7:12 
GeneralRe: Thank you! Pin
Juan Manuel Elosegui28-Jan-07 4:12
Juan Manuel Elosegui28-Jan-07 4:12 
Hi Miguel:
Thanks for your comments.

Now the control work properly

Greetings
JME.
GeneralRe: Thank you! Pin
MCAST7628-Jan-07 13:52
MCAST7628-Jan-07 13:52 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.