onSetText and TfloatField lazarus / 16-Databases ---------------------------------------------------------------------- Nicola Gorlandi · 2023-12-19 12:54 Hi, I have a Tfloatfield with an onSetText assigned, if I put some value in it using asFloat the onSettext do not fire. The same for a string field using asString it works. Is this correct ? How to manage this kind of requirement ? I am using ZeosDb and the latest version of Lazarus released on Windows. Many thanks in advance ---------------------------------------------------------------------- kwyan · 2023-12-19 13:13 OnSetText is for text representation of the field. If you get the field AsFloat, it will not trigger OnSetText ---------------------------------------------------------------------- Nicola Gorlandi · 2023-12-20 07:42 Is possible to do something similar to onsettext for tfloatfield ? ---------------------------------------------------------------------- kwyan · 2023-12-20 14:05 I think you want to use OnSetText to use your own logic to convert string to float. Then you can use TFloatField.Text (and not TFloatField.AsString). The following logic is to just to demonstrate behaviour: 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 TForm1.Button1Click(Sender: TObject);begin   SQLQuery1.Edit;   SQLQuery1unit_price.Text := '123.00/unit'; // It will call OnSetText which will trim the last 5 charactersend; procedure TForm1.SQLQuery1unit_priceSetText(Sender: TField; const aText: string   );begin   Sender.Value := StrToFloat(Copy(aText,1,Length(aText)-5));end; ---------------------------------------------------------------------- Nicola Gorlandi · 2023-12-21 06:32 Many thanks, that is exactly what I would like to avoid in order to do not change the code for each assignement of that field; unfortunately I have a lot.