Click here to Skip to main content
Click here to Skip to main content

A Calculator Control Box

By , 25 Nov 2005
 

Sample Image - CalculatorBox.jpg

Introduction

Accepting input from the user is always a big challenge in software development. I faced many cases where the user needs to be controlled by the application to provide proper input. So, I designed some controls to provide that feature. But I felt there are some cases where the more than just controlling the input is required. For example, if user needs to input some amount, then the user might expect a calculator to do initial calculation for a particular field. In that case, the user uses his/her own preferred calculator to do the initial calculation. Some of them use their brain, some use a physical calculator, and some use the calculator available with Windows. All of these are out of the scope of the application that the user is using. So, I always felt the need to develop a calculator control, which will provide a very similar interface as the standard calculator found in the market. That was the motivation to develop this calculator box. This calculator box can be used instead of using a restricted text box control.

Description

The CalculatorBox is a user control, which provides a specific feature to provide numerical input, especially for financial information. This control can be used as a text box control. It is more like a combo box control. It has two modes. One is the normal mode where the user can provide input for decimal numbers. Whenever the user wants to do some mathematical operations, the user can click on the arrow at the left, like in a combo box. It will display a calculator at the best possible place. The user can click on the calculator buttons, or use the keyboard to do the calculations. In text mode, if the user clicks any operation key (Add, Subtract, Multiply, or Divide), then it will automatically switch to calculator mode with the button pressed. If the calculator loses its focus, then automatically it will switch to text mode and the calculator will disappear.

Sample Image

If the user made some mistake in the calculation and wants a previous value, then the user can press the Esc button and the control will reset to the previous value.

This control has two properties: the Text property will provide whatever is available in the text box, and the Value property will provide the decimal value.

1.1 New Support

Culture Support

I use the current culture information from the CultureInfo class to decide the character for the the decimal point. The decimal point is used for display as well as to accept input from the user. For example, the Spanish language uses coma as a decimal separator. So, if the user sets the current culture as Spanish, then the calculator control will automatically use the coma as the decimal separator.

Culture Support

License

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

About the Author

H. S. Masud
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberMarkDaniel5 Jan '12 - 12:02 
GeneralMy vote of 5memberversion_2.017 Jun '11 - 18:20 
GeneralMy vote of 4memberShinigamae7 Oct '10 - 2:49 
GeneralDecimal point not showing in decimal button in calculator.memberbodycode18 Aug '10 - 5:38 
GeneralMy vote of 2memberAjizen13 Oct '09 - 8:01 
General[My vote of 2] questionsmemberfmzl14 Jun '09 - 22:27 
Questioncan u help me?memberyasrebi29 May '08 - 23:37 
Generalhello can you help mememberwwfinz6 Jun '07 - 7:19 
QuestionWhat would be really cool....memberM i s t e r L i s t e r4 May '07 - 10:55 
QuestionHow to show it above all controls & formmemberAnupam2128514 Jul '06 - 21:48 
AnswerRe: How to show it above all controls & formmemberH. S. Masud22 Sep '06 - 19:18 
AnswerRe: Calculator.CalculatorBoxmemberH. S. Masud24 Jun '06 - 23:27 
Generalproblem with calculator control boxmemberMonicaPaver3 May '06 - 6:33 
AnswerRe: problem with calculator control boxmemberH. S. Masud3 May '06 - 20:32 
GeneralGreat IdeamemberVectorX22 Dec '05 - 8:49 
JokeRe: Great IdeamemberH. S. Masud24 Dec '05 - 4:29 
GeneralNice Control, but let me point out a little shortfall in culture support.....memberagapitar29 Nov '05 - 8:57 
AnswerRe: Nice Control, but let me point out a little shortfall in culture support.....memberH. S. Masud29 Nov '05 - 19:46 
GeneralGreat JobmemberShahriar Hyder25 Nov '05 - 21:32 
AnswerRe: Great JobmemberH. S. Masud25 Nov '05 - 22:40 
GeneralRe: Great JobmemberShahriar Hyder26 Nov '05 - 17:54 
QuestionExcellent Solutionmembersulo2422 Feb '06 - 16:34 
AnswerRe: Excellent SolutionmemberH. S. Masud22 Feb '06 - 19:04 

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 25 Nov 2005
Article Copyright 2005 by H. S. Masud
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid