|A Simple Calculator Application|
Normally calculator displays are right aligned. Therefore we’ll introduce that property to our text box. For that, select the text box by clicking on it. Then go to its properties panel and find the property called TextAlign from the list.
(you can find the properties panel on the lower right corner of the window).
The default value for the TextAlign property is Left. Click on the word Left and a drop down list will open. Select Right from that list and press ENTER.(Figure 1)
- This if clause filters non-numeric characters that should to be handled by this special code.
- If the entered character is decimal sign (.), it is handled by this code segment.
- Calculator display can have only one decimal character. This code segment checks whether the text box already contains a decimal sign and if so, the event is handled without inserting the newly typed decimal sign to the text box.
- If the entered character is minus sign (-), it is handled by this code segment.
- Calculator display can have minus character (-) only at the front of a number. This code segment checks whether the text box already contains some text and if so, the event is handled without inserting the newly typed minus sign to the text box.
- This segment allows the user to delete the already entered characters by pressing Backspacekey.
- All the other non-numeric character events are handled without inserting the characters to the text box.
Now we have completed customizing the text box. Press F5 to run the application and check whether it has all the characteristics we have introduced.