如何格式化DBGrid列以显示两个小数位? [英] How to Format a DBGrid Column to Display Two Decimal Places?

查看:171
本文介绍了如何格式化DBGrid列以显示两个小数位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想格式化特定的单元格以强制两个小数位。数据来自一个ElevateDB存储过程并挂接到一个TDataSource中。

I would like to format specific cells to force two decimal places. The data is coming from an ElevateDB stored procedure and hooked into a TDataSource.

编辑:SQL编程注意:

我不知道这是否只是一个ElevateDB问题。在了解字段编辑器之前,我尝试通过在存储过程中使用CAST(NumericField as varchar(10))语句在SQL级别格式化数据。通过这样做,它没有在这个特定字段的字段编辑器中公开 DisplayFormat 属性。

I wasn't sure if this was just an ElevateDB issue or not. Before knowing about the Fields Editor, I attempted to format the data at the SQL level by using a CAST (NumericField as varchar(10)) statement inside the stored procedure. By doing so, it did not expose the DisplayFormat property inside the fields editor for this particular field.

当我从存储过程中删除CAST()语句时,显示格式属性显示在字段编辑器

When I removed the CAST() statement from the stored procedure, the DisplayFormat property showed up in the Fields Editor.

推荐答案

您可以通过格式化底层字段格式化DBGrid列。如果未完成,请在数据集中创建静态字段,然后将有问题的字段的DisplayFormat属性设置为 0.00 ,然后完成。

You can format the DBGrid columns by formatting the underlying fields. If not done, create static fields in your dataset and then set the DisplayFormat property of the field in question to 0.00 and you are done.

这篇关于如何格式化DBGrid列以显示两个小数位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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