格式化标签以显示00.00 [英] Format a label to show 00.00

查看:130
本文介绍了格式化标签以显示00.00的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用标签显示我的应用程序中输入的当前金额..



所以基本上有一个键盘从1-9开始,包括0和00.



我希望标签始终显示00.00,直到输入一个数字。



所以如果我想输入12英镑的价格。然后我将在键盘上输入1200,它将在标签中显示为12.00。因此,每次输入一个数字时,它会从右向左移动。



有人推荐label.Content =00.00,但这不起作用,因为我按下的那一分钟键盘上的1然后显示00.001..



所以基本上我想输入的数字代替已经存在的00.00。

I am using a label to display the current amount entered in my application..

So basically there is a keypad that goes from 1-9 including 0 and 00.

I want the label to display 00.00 at all times until a number is entered.

So if i wanted to enter the price £12. Then i would enter 1200 on the keypad and it would come up as 12.00 in the label. So its bascically moving from right to left each time a number is entered.

Someone recommended label.Content = "00.00", but that doesnt work because the minute i press 1 on the keypad then it displays "00.001"..

So basically i want the numbers entered to replace the 00.00 that are already there.

推荐答案

通过使用键盘和标签,您试图模仿一些历史设备,如自动取款机或类似的东西。不要这样做。我只能混淆用户并让他们发疯。使用现代计算机模拟旧坏机器的流行想法是适得其反的。所有数据都应以自然的方式呈现,并且恰好在其输入的位置,而不是其他地方。不应该有标签,特别是没有键盘。



例如,使用此控件: https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox [ ^ ]。



-SA
By using the keypad and label you are trying to mimic some historical equipment like a cash machine, or something like that. Don't do it. I can only confuse the users and drive them mad. The popular idea of mocking old bad machines using modern computer is counter productive. All data should be presented in a natural way and exactly in the place it its typed in, nowhere else. There should not be a label and, especially, no keypad.

Use, for example, this control: https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox[^].

—SA


一位程序员给我提供了答案,这个答案实际上是两行代码,与我尝试过的20多行注释代码相反。



我只需将数字乘以10然后按下按钮编号然后再将它除以100。
A fellow programmer had provided me with the answer which was indeed two lines of code as oppose to the 20+ lines of commented out code that i had tried and failed with.

I just had to times the number by 10 then at the button number then divide it by 100 again.


这篇关于格式化标签以显示00.00的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆