How do I add a Pascal computed column in DBGrid? lazarus / 31-LCL ---------------------------------------------------------------------- petejones · 2022-05-20 22:42 How do I add a Pascal computed column in DBGrid? I have a complex calculation to make for a column and have to do it in Pascal (rather than SQL). Is there a grid event I can hook into that will allow this? OnDrawColumnCell perhaps? Cheers Pete ---------------------------------------------------------------------- rvk · 2022-05-20 22:54 Why not add the calculated column as TField to the dataset (DBGrid.Dataset)? https://forum.lazarus.freepascal.org/index.php?topic=21006.0 https://lazarus.lazarus.freepascal.narkive.com/I7vozZ0F/can-t-create- calculated-field ---------------------------------------------------------------------- petejones · 2022-05-20 23:06 Yes that would do, thanks. ---------------------------------------------------------------------- petejones · 2022-05-21 15:49 How do I get round the read-only/not in edit mode issue? I'm doing all this in code, so I set ReadOnly = False on the Query and the DataSet to Edit, but I still get an error: "DataSet is read-only" ---------------------------------------------------------------------- rvk · 2022-05-22 15:40 Quote from: petejones on May 21, 2022, 05:49:45 pmHow do I get round the read-only/not in edit mode issue? I'm doing all this in code, so I set ReadOnly = False on the Query and the DataSet to Edit, but I still get an error: "DataSet is read-only" Why would you want to change a calculated field? It's calculated so it's read only by nature. In TSQLQuery.OnCalcFields you can set the value with FieldByName('calc').asSomething := abc; to fill the value. But you shouldn't send this to the server. So where are you having trouble with a read-only field? (otherwise show us a simple example)