小编Mor*_*mie的帖子

Delphi TFloatField.DisplayFormat 用于小于 1.0 的数字字段

这是我的程序。

procedure format_integer_field(Atable: TDataSet);
 var i: integer;
begin
 if Atable.Active then
 if Atable.FieldCount > 0 then
 with Atable do
 begin
  for i:= 0 to FieldCount-1 do
  if (Fields[i] is TIntegerField) then
  begin
   (Fields[i] as TIntegerField).DisplayFormat := '###,###';
   (Fields[i] as TIntegerField).EditFormat := '#';
  end
  else
   if (Fields[i] is TFloatField) then
  begin
   (Fields[i] as TFloatField).DisplayFormat := '###,###.##';
   (Fields[i] as TFloatField).EditFormat := '#.##';
  end;
 end;
end;
Run Code Online (Sandbox Code Playgroud)

在输入“0.9”之类的数字并且结果为“.9”之前,这一切正常。如何在小于“1”的浮点数之前有千位分隔符和零。

database delphi vcl string-formatting tfield

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

database ×1

delphi ×1

string-formatting ×1

tfield ×1

vcl ×1