Andriws Luna Posted March 2, 2018 Share Posted March 2, 2018 http://i66.tinypic.com/206eq39.png How to change the mask of a column in dbgrid to always remain with two decimal places? I1m using Trial edition, 1.0.0.1424 version. Link to comment Share on other sites More sharing options...
alfr Posted March 3, 2018 Share Posted March 3, 2018 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.) Link to comment Share on other sites More sharing options...
Andriws Luna Posted March 5, 2018 Author Share Posted March 5, 2018 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 More sharing options...
Andriws Luna Posted March 8, 2018 Author Share Posted March 8, 2018 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 More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now