小值的格式说明符 [英] format specifier for small values

查看:87
本文介绍了小值的格式说明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家,

DataGridView用于显示一些测量值.在这些值中有电流.它们存储在应用程序的Ampères中.

由于这些值相对较小,因此我想告诉DataGridView改为显示Milliampères.

显示大幅度的可能性 [每千个 [

Hi experts,

a DataGridView is used to display some measured values. Among those values are currents. They are stored in Ampères within the application.

Since those values are relatively small, I would like to tell DataGridView to display Milliampères instead.

There is a possibility to display large magnitudes[^]. And there is one for per mille[^] values. But the first is the wrong way round, the latter inserts an additional per-mille-symbol.

What format specifier multiplies a value by 1000 before displaying it?


The grid is data-bound. So there is no code that sets an individual cell''s value. Therefore I''m looking for a format specifier that can be used as DataGridViewCellStyle.Format.

推荐答案

为什么您可以这样做(value*1000).ToString("0.00")?
Why can''y you do this (value*1000).ToString("0.00") ?


只需删除& ChrW(&h2030)部分,因为那是每个英里的符号.您也可以将其替换为所需的符号.您可以使用charmap(开始->运行...->类型:charmap)查找合适的宽字符,或者只需在格式字符串中添加"amp"即可.

祝你好运!
Just delete the & ChrW(&h2030) part because that is the per-mille-symbol. You could also replace it with a symbol you like. You can use charmap (start -> run... -> type: charmap) to to lookup a wide-char that is suitable or just simply add " amp" to the format string.

Good luck!


我通过在应用程序数据和网格之间放置一个视图模型类来做到这一点.网格绑定到这些绑定帮助器的列表,而不是直接绑定到业务对象的列表.然后,绑定帮助器可以执行需要的任何两种方式的转换,以将数据转换为用户想要查看的形式(即单位转换,不仅是X-> mX,而且是m-> ft和其他类似的东西).
I do this by having a view-model class that sits between the application data and the grid. The grid is bound to a list of these binding helpers, instead of to the list of business objects directly. The binding helper can then perform whatever two way translation is needed to get the data into the form that the users want to see it (i.e. unit conversions, not just X->mX but m->ft and other similar things).


这篇关于小值的格式说明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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