how to convert textbox format to money with comma sepration format ( like 100,236,563 ) in c#?

大城市里の小女人 提交于 2019-12-12 05:19:25

问题


I have textbox and I need to convert format of that to curency and money format with comma seprator ( like 12,654,500 ) can anybody help me ??

private void txtMuchMoney_TextChanged(object sender, EventArgs e)
{

}

回答1:


Use this mask:

$000,000,000

Refer to this MSDN article for more information on masks.

$ : Currency symbol. The actual character displayed will be the currency symbol appropriate to the format provider, as determined by the control's FormatProvider property.

, : Thousands placeholder. The actual display character used will be the thousands placeholder appropriate to the format provider, as determined by the control's FormatProvider property.

So, you might also want to set the FormatProvider property if you not get the desired behavior out-of-the-box.




回答2:


Use MaskedTextbox and set the Mask property to 00,0000,000.




回答3:


How about using a MaskedTextBox instead
https://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask(v=vs.110).aspx the mask property value should simply be 00,0000,000



来源:https://stackoverflow.com/questions/35722882/how-to-convert-textbox-format-to-money-with-comma-sepration-format-like-100-23

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!