在带有千位分隔符(,)的文本框中输入数字 [英] enter digits in text box with thousands separator (,)

查看:111
本文介绍了在带有千位分隔符(,)的文本框中输入数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我输入数字时,它将显示为:123456789
但是当用户输入数字时,我想用3位数字来分隔3位数字(例如Windows中的计算器):123,456,789

Hi,

When I enter digits, it will show like this: 123456789
but I want to seperate 3 by 3 digits as user enters digits(like calculator in windows):123,456,789

推荐答案

如果您谈论的是Web或Winform,则不太清楚.

无论哪种情况,我都会选择一个带遮罩的文本框,示例:
网址:
增强的文本框控件 [已屏蔽的C#TextBox控件 [ MSDN:演练:使用MaskedTextBox控件 [
Not too clear if you are talking of web or winforms.

For either case, I would go for a masked textbox, samples:
Web:
Enhanced Textbox Control[^]

Winforms:
Masked C# TextBox Control[^]
MSDN: Walkthrough: Working with the MaskedTextBox Control[^]


此处,来自Micrrosoft文档:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx [ ^ ]

在这个例子中查看perticulat:
Here, from the Micrrosoft documentation:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^]

Look perticulat at this example:
value = 1234.567890;
Console.WriteLine(value.ToString("0,0.00", CultureInfo.InvariantCulture));
// Displays 1,234.57


这篇关于在带有千位分隔符(,)的文本框中输入数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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