有没有办法去掉 TCurrencyEdit 控件中的 $ 字符?
我正在 Delphi 7 中工作,并尝试创建一个可以输入小数的编辑框。
除了 TCurrencyEdit 之外,Delphi 7 基础库中似乎没有任何其他东西可以实现此目的。但是,它会在值的开头附加一个 $
。有没有办法去掉这个“功能”?
I'm working in Delphi 7 and trying to make an edit box where you can enter decimals.
There doesn't appear to be anything in the Delphi 7 base library for this other than TCurrencyEdit. However, it tacks on a $
to the beginning of the value. Is there anyway to get rid of this "feature"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(你不能在普通的
TEdit
中输入小数吗?)据我所知,Delphi(任何版本)附带的VCL中没有
TCurrencyEdit
。无论如何,为此,您可以使用TMaskEdit
。也许格式#999999999.99;1;_
就可以了。不过,我不会赞扬这个解决方案的用户友好性!我相信,最用户友好的做法是使用没有任何限制的普通
TEdit
。然后您可以在需要时解析用户输入的文本。然后您可以接受诸如1 000
以及1000
和1000.00
之类的输入。您甚至可以尊重本地小数分隔符,并接受1000,00
(例如在瑞典)。[但要确保没有歧义。如果用户输入
1000,000
并认为这等于 1000 克朗和 000 öre,那么您可能会感到不安,然后您从他的帐户中取出 1000000 克朗!](Can't you enter decimals in an ordinary
TEdit
?)As far as I know, there is no
TCurrencyEdit
in the VCL that ships with (any version of) Delphi. Anyhow, for this, you could use theTMaskEdit
. Perhaps the format#999999999.99;1;_
will do. Still, I wouldn't praise this solution for its user-friendlyness!The most user-friendly thing to do, I believe, is to use an ordinary
TEdit
with no restrictions. Then you can parse the text entered by the user when you need to. And then you can accept inputs like1 000
as well as1000
and1000.00
. You can even respect the local decimal separator, and accept1000,00
(in Sweden, for instance).[But make sure that there is no ambiguity. The user might get upset if he enters
1000,000
and considers this to equal 1000 kronor and 000 öre, and then you take 1000000 kronor from his account!]