Delphi DBGrid Format Display Values

末鹿安然 提交于 2019-12-04 04:48:57

问题


I need to format values in a DBGrid to display in a certain format ex '#,##0.00'. Any idea how to do that?

Regards, Pieter


回答1:


Each Field in your DataSet has two events: OnGetText and OnSetText. Use event OnGetText of desired fields and use Format function to format the value using a mask.




回答2:


you can use the DisplayFormat property of the field to format.

check this sample

TFloatField(YourDataSet.FieldByName('field')).DisplayFormat := '#,##0.00';


来源:https://stackoverflow.com/questions/3619835/delphi-dbgrid-format-display-values

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