本文介绍了Vb如何设置numericupdown控件以显示值作为货币?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何设置NumericUpDown控件以显示值作为货币? ...为$ 12,345.09 我是什么尝试过: 我在互联网上搜索但我找不到任何关于如何向NumericUpDown添加货币的信息。到目前为止,我的结果是12,345.09 ......而我正在寻找$ 12,345.09 我正在使用VB 解决方案 12,345.09 我的尝试: 我搜索过互联网但我找不到任何关于如何将货币添加到NumericUpDown的内容。到目前为止我的结果是12,345.09 ......我正在寻找 12,345.09 我正在使用VB 要做到这一点,你必须创建自己的CurrencyUpDown控件,并从NumericUpDown派生它。 1)创建一个名为CurrencyUpDown的CustomControl 2 )在Solution Explorer窗格的顶部,单击显示所有文件。 3)打开项目的CurrencyUpDown分支,然后双击CurrencyUpDown.Designer.vb 4)将Inherits行从UserControl更改为NumericUpDown 5)保存并关闭文件。 6)转到控件的代码视图,然后添加覆盖方法: 受保护的 覆盖 Sub UpdateEditText() Text = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol& Value.ToString() 结束 Sub How can I set a NumericUpDown control to display value as currency?...as $12,345.09What I have tried:I have searched the internet but I couldn’t find anything on how to add currency to a NumericUpDown. My result so far is 12,345.09 …and I’m looking for $12,345.09I'm using VB 解决方案 12,345.09What I have tried:I have searched the internet but I couldn’t find anything on how to add currency to a NumericUpDown. My result so far is 12,345.09 …and I’m looking for12,345.09I'm using VBTo do that, you have to create your own CurrencyUpDown control, and derive it from NumericUpDown.1) Create a CustomControl called CurrencyUpDown2) At the top of the Solution Explorer pane, click "Show all files".3) Open the CurrencyUpDown branch of your project, and double click "CurrencyUpDown.Designer.vb"4) Change the Inherits line from UserControl to NumericUpDown5) Save and close the file.6) Go to the Code view for the control, and add an override method:Protected Overrides Sub UpdateEditText() Text = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol & Value.ToString()End Sub 这篇关于Vb如何设置numericupdown控件以显示值作为货币?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 22:23