Jump to content

DbGRid Float Format


Andriws Luna

Recommended Posts

If you are using a TADOQuery you can set DisplayFormat on each field i.e. to "0.00"  (Right the query component to get to the fields editor - to be able to add the various fields.)

alfr Thanks to the reply.

I use TFDMemTable and, at design time, putting the component on the screen works, but I'm using it at runtime and the code below is not working.

 

FDataset.CopyDataSet(DS,[coStructure,coRestart,coAppend]);

TFloatField(FDataset.FieldByName('PrecoVenda')).DisplayFormat := '0.00';

Link to comment
Share on other sites

 

I solved the problem. The dataset code is correct, the problem was when I added the columns in the grid through this code.

 

With DbGridPrincipal.Columns.Add DO

BEGIN

FieldName := 'PrecoVenda';

Alignment := taRightJustify;

Title.Caption := 'Preço';

Title.Font.Style := [fsbold];

Title.Alignment := taCenter;

Width := 80;

END;

 

 

As the addition of columns happened before the dataset was written, the grid did not perform very well.

I put the creation of the columns after the first query, that is, with the dataset filled in, and it worked.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...