Winform文本框千位分隔符要钱? [英] Winform textbox thousand seperator for money?

查看:39
本文介绍了Winform文本框千位分隔符要钱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to enter value for money in txtMoney (textbox),I want when LostFocus, it will be add thousand seperator. My money look like 1.500, 2.000.000,..., they are integer only, can divide by 100. How can I do it?

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

void txtMoney_LostFocus(object sender, EventArgs e) {

}

推荐答案

    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;
    }

该示例适用于越南语格式.

The example is for Vietnamese format.

更多信息:标准数字格式字符串

这篇关于Winform文本框千位分隔符要钱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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