开发者

How to limit the number of digits in a calculator program for the windows phone?

I'm hav开发者_JAVA百科ing a hard time limiting the number of digits allowed on the text box. I have this code right here:

if (inputPanelTextBox.Text.Length >= 16)

I just don't know what to do under the if statement. What I want to happen is the same thing as the e.handled = true. When the text reaches 15 digits, don't do anything to it if the user attempts to add more digits.

Any help would be very helpful. Thank you so much in advance.


The way I would do it handle the OnKeyDown event.

inside of the handler, check the length of the string (as you have done), then set the e.Handled property to true, this will stop the character from being added to the textbox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜