How to handle when the backspace button is pressed and the input panel has digit grouped numbers. E.g. 434,343,334.232

后端 未结 1 549
一整个雨季
一整个雨季 2021-01-27 20:24

I am making a calculator in c# for the windows phone and I\'m struggling right now.

Say the user wrote the digits 123,456. What I want to happen is when the user hits t

相关标签:
1条回答
  • 2021-01-27 20:42

    You could use String.Format("{0:n}", value) for displaying the numbers with commas. If the user enters commas, strip them when storing them in your program.

    Basically, you can store the number internally in the program as a numeric type (such as Decimal). When the user hits the backspace key (or otherwise enters text), parse the numeric value out of the string and then update the display with the String.Format operation using the numeric value.

    0 讨论(0)
提交回复
热议问题