【问题标题】:Winform textbox thousand seperator for money?Winform文本框千位分隔符的钱?
【发布时间】:2014-10-27 02:58:57
【问题描述】:

我需要在txtMoney(文本框)中输入物有所值,我想在LostFocus 时添加千位分隔符。我的钱看起来像 1.500, 2.000.000,...,它们只是整数,可以除以 100。 我该怎么做?

void txtMoney_LostFocus(对象发送者,EventArgs e) {

}

【问题讨论】:

    标签: string winforms textbox format


    【解决方案1】:
        private readonly CultureInfo _provider = CultureInfo.CreateSpecificCulture("vi-VN");
        private decimal ParseMoney
        {
            get { return decimal.Parse(txtMoney.Text, _provider); }
        }
    
        private string FormatMoney
        {
            get { return string.Format(_provider, "{0:##,###}", ParseMoney); }
        }
    
        private void txtMoney_Leave(object sender, EventArgs e)
        {
            txtMoney.Text = FormatMoney;
        }
    

    示例为越南语格式。

    更多信息:Standard Numeric Format Strings

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多