Jump to content

Format field with DBGrid.OnDrawDataCell property


mierlp

Recommended Posts

Hi

In VCL you can use this code to format a field. Within uniDBGrid this event is not available

Quote

procedure TFormMain.DBGridCompareDrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);
begin
if Field.Name = 'FIELDNAME' then
TFloatField(Field).DisplayFormat := '#,##0.00';
end;

 

Link to comment
Share on other sites

this is the same 

procedure Tfra.UniDBGridRoomDrawColumnCell(Sender: TObject;
   ACol, ARow: Integer; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin
   if Column.FieldName = 'Rate' then
   TFloatField(Column.Field).DisplayFormat:= '0.00' ;
End;

but I didn't test it 

 

regards

Link to comment
Share on other sites

Hi

You're solution works fine...thanks.

I have created in the main table a lookup field for showing a TIME value from a other table.
When i created the lookup field and set the type to TIME or STRING then you can't
format it with this code. Then i got a exception error. When leaving the code it
show the time value but Always in HH:mm:ss 

I think it's not possiblie to format a lookup field this way.

But thanks for the solutions

 

 

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...