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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...