如何自定义格式文本框 [英] how to Custom formate Textbox
本文介绍了如何自定义格式文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
40 * 7.5 =
文本框= 5.33333333333333
我需要显示这样的6个数字
文本框= 5.333333
40*7.5=
Text box =5.33333333333333
I Need to display Just 6 Numbers Like this
Text box =5.333333
推荐答案
请看我对这个问题的评论。
这是如何:
https://msdn.microsoft.com/en-us/library/system.double.tostring %28v = vs.110%29.aspx ,
https://msdn.microsoft.com/en-us/library/dwhawy9k(v = vs.110).aspx ,
https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs。 110).aspx 。
有任何疑问吗?
- SA
Please see my comment to the question.
This is how:
https://msdn.microsoft.com/en-us/library/system.double.tostring%28v=vs.110%29.aspx,
https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx,
https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx.
Any questions on that?
—SA
对于初学者来说,40 * 7.5不等于5.33333333333333
它应该是40 / 7.5 = 5.33333333333333
算一算,然后在设置文本框之前格式化文本。
For starters, 40 * 7.5 does not equal 5.33333333333333
It should be 40 / 7.5 = 5.33333333333333
Do your math, then format the text before setting the Textbox.
double dv = 40 / 7.5;
string newvalue = string.Format("{0:0.00}", dv);
textbox1.text = newvalue;
这篇关于如何自定义格式文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文