Frederick Posted April 28, 2020 Share Posted April 28, 2020 In a TUniDBGrid, I want a cell to show a blank value when the field of the data source linked to it is 0.00. I am using the following event of the grid but the cell still shows the zero. procedure TForm.grdGridSetCellValue(Sender: TObject; ACol, ARow: Integer; AField: TField; var Value: Variant); begin if Afield.FieldName='debit' then begin if Value='0.00' then Value:=''; end; end; What am I missing here or is this the correct event to use? -- Frederick (UniGUI Complete - Professional Edition 1.90.0.1530) Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted April 29, 2020 Share Posted April 29, 2020 Hi, You can use TField.DisplayFormat:= ',#.##'; Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 29, 2020 Author Share Posted April 29, 2020 6 hours ago, Freeman35 said: Hi, You can use TField.DisplayFormat:= ',#.##'; Thanks for the post. I solved the problem as follows:- 1. Set the field's DisplayFormat to '#,0.00;-#,0.00; ' (There is a space after the second semi colon) and 2. Add the following code in the field's OnGetText event procedure TUniMainModule.qryObcreditGetText(Sender: TField; var Text: string; DisplayText: Boolean); begin Text := FormatFloat( TNumericField( sender ).DisplayFormat , Sender.Value ); end; The setting of the DisplayFormat property is the same as I would use in a Delphi Windows program but for some reason in UniGUI, the setting is not recognized and rubbish characters are shown in TUniDBGrid if the OnGetText event is blank. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.