Subject Re: [IBO] displaying calculated fields in TIB_Grid ???
Author Helen Borrie
At 08:04 AM 02-05-01 +0000, you wrote:
> I'm having trouble displaying Calculated Fields in TIB_Grid,
>i have an empty table, when i add a record, the calculated fields
>are
>correctly displayed, but when i add again another record, the value
>of
>the calculated fields of the second record display in the grid will
>also be the value of the first record???
>
> Is there anybody can give me a brief example/code of displaying
>Calculated Fields in TIB_Grid??? thanks a lot...

If you have the calculated fields fully defined in the dataset, then they will display in the grid just as any other column.

You need to declare the CalculatedFields property, one line in the property editor for each calc field, just like field definitions in a Create Table statement, e.g.
MYINTCOLUMN INTEGER NOT NULL
MYSTRCOLUMN VARCHAR ( 50 )
MYDATECOLUMN DATE

Then, of course, you need to write a handler for the dataset's OnCalculateFields event - remember to code for the case where other fields contributing to the calculation contain null or invalid values.

You can call the CalculateFields method for the dataset or for the row, whenever the contributing data have changed. I *think* that the only time it gets called automatically is when the dataset first opens.

H.



All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________