Format displayed cell value lazarus / 16-Databases ---------------------------------------------------------------------- P.curtis · 2020-04-30 18:44 Hi All, I am using MemDataset and RxDBGrid. How can I format a longint column with this FormatDateTime('hh:nn:ss', CELL_VALUE / SecsPerDay Thanks for your help. ---------------------------------------------------------------------- winni · 2020-04-30 19:41 Hi! It is not clear what you want. Describe it please Winni ---------------------------------------------------------------------- eljo · 2020-04-30 19:45 There is a getDisplayText event somewhere the dataset the field or the grid, probably the field, you write a handler for it and you can format the display text on what over conditions you like. ---------------------------------------------------------------------- P.curtis · 2020-04-30 19:54 I cant find the event. ---------------------------------------------------------------------- eljo · 2020-04-30 19:59 Quote from: P.curtis on April 30, 2020, 09:54:23 pmI cant find the event. provide a simple demo that I can modify for you, please keep in mind I do not have rxlib installed nor I plan to do so, so... use the default dbgrid for this demo please or instead of a grid use a simple dbEdit, listbox etc you can addapt it to rxdbgrid after that. Never mind I got off my fat ass and actually tried the memdataset thing I see the problem now here is a quick n dirty solution to your problem. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure SetFieldTextFormater(const aDataset:TDataset;const aFieldName:string; aTextEvent:TFieldGetTextEvent);var  Fld :TField;begin  Fld := aDataset.FieldByName(aFieldName);  Fld.OnGetText := aTextEvent;end;  Assuming that you have the memdataset in a form (or datamodule) and assuming that form's name is form1 you declare a new method in that form like the following code. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   TForm1 = class(TForm)    MemDataset1: TMemDataset;  private   public   procedure FormatIntToTime(Sender: TField; var aText: string; DisplayText: Boolean);  end; implementation procedure TForm1.FormatIntToTime(Sender: TField; var aText: string; DisplayText: Boolean);begin  if DisplayText then begin     aText := FormatDateTime('hh:nn:ss', Sender.AsLongint / SecsPerDay);  end;end; and use all the above on the form's or datamodule's on create event like this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TForm1 = class(TForm)    MemDataset1: TMemDataset;    procedure FormCreate(Sender: TObject);  private  ..  ..  .. implementation procedure TForm1.FormCreate(Sender: TObject);begin  SetFieldTextFormater(MemDataset1,'MyTimestampField', @FormatIntToTime);end; The problem appears to be that the memdataset does not make the property Fields published and you do not have access to them at design time so you have to do it at runtime. EDIT: One last thing the above code must be executed after the memdataset is active and the fields are created, on top of that it needs to be executed every time the memdataset recreates the fields and the event looses its link to the method above, so the form onCreate thing is just a convenient placeholder to showcase the process. ---------------------------------------------------------------------- P.curtis · 2020-04-30 20:28 I hope this helps. Instead of displaying 3056 it should display 00:00:30.56. Thanks for the offer to help. ---------------------------------------------------------------------- eljo · 2020-04-30 20:41 Quote from: P.curtis on April 30, 2020, 10:28:31 pmI hope this helps. Instead of displaying 3056 it should display 00:00:30.56. Thanks for the offer to help. find attached the demo with the code added. It now formats the value as a time but the conversion you provided is not correct and since I have no idea what it saves or how it acquired it you will have to either provide us with the details or try to figure it out your self oh and a screen shot of what it produces in my computer. ---------------------------------------------------------------------- P.curtis · 2020-04-30 21:04 Sorry my mistake 30.56 not 3056. EXCELLENT HELP. Thanks.