I need to add a textbox in my application that starts showing with the value 0.00 just like a ATM, as you type the numbers then it keeps the two decimal point until satisfied with the value for example the sequence to end up of a value of 1023.00 would be (as I type)
0.01
0.10
1.02
10.23
102.30
1023.00
Is this possible to do in a windows forms application?. I am just not sure how to go about it.
Thank you.
In this kind of scenario I would not use a textbox, but a label or a read-only textbox. To get the user input just use the key-press event on your form (you have to enable KeyPreview on the form too) – then just remember the keys/numbers pressed and output the format you are targeting – should be a rather easy algorithm (Char.IsNumber, and String.Format might come in handy):
Note: Why not use a textbox – because it’s internal logic with select/replace/remove/type is so overcomplicated that the cases you would have to check are just to much to handle gracefully – so instead of trying to change a cannon into a sling you should start with the sling.