Create a calculated field at runtime and more
Posted on 2003-01-15
I use next code to create my runtime calculated field:
MyField := TFloatField.Create(Table1);
with MyField do
FieldName := 'MyField';
Calculated := True;
DataSet := Table1;
Name := Table1.Name + FieldName;
Table1.FieldDefs.Add(Name, ftString, 250, false);
But I need to use the others fields of the table and I don't know how to add these.
My table have , for example, Field1 and Field2. If I try to use the calculated field with Field2, I get an error that the Field2 don't exist. How to add?
In same time this calculated field is used inside a DBGrid. How to add a column at runtime for this field?