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

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