Board index » delphi » How to add calculate field to Dbgrid

How to add calculate field to Dbgrid

Hi

I need the way or an example showing how to add a calculate field to the
DbGrid.

Thanks

 

Re:How to add calculate field to Dbgrid


you need to add the field to the dataset tha provides data to the grid, not
to the grid itself
to do this use tdataset.fieldefs.add to add  a new field.Then set in code
the appropriate properties, especially tfield.calculated/  You also need to
add an oncalcfield event handler for the tdataset, which will fill the
newly added field with data

HTH

--
Boris Ingram, Cyborg Software
boris...@iafrica.com
100076.3...@compuserve.com
http://www.pcb.co.za/users/borising/cyborg.htm

Rabeh Mansour <khkha...@netvision.net.il> wrote in article
<01bc428b$659e6ce0$b0035ac2@mansour>...

Quote
> Hi

> I need the way or an example showing how to add a calculate field to the
> DbGrid.

> Thanks

Re:How to add calculate field to Dbgrid


Hi

On 6 Apr 1997 13:06:47 GMT, "Rabeh Mansour"

Quote
<khkha...@netvision.net.il> wrote:

>I need the way or an example showing how to add a calculate field to the
>DbGrid.

You have to add the calculated field to the table not to the dbgrid.
Double-click the table to view the field-editor and select new field
in a right-click-context-menu. There you can enter all information for
a calculated field. You have to set up an event handler for the onCalc
event of the table where you calculate the value of the field each
time Delphi calls this event. Remember this procedure could be called
very often, so make sure you have fast code there.

ciao Sebastian Kanthak

Sebastian Kanthak
Email   : sebastian.kant...@muehlheim.de
Homepage: http://www.muehlheim.de/~skanthak/
PGP-Key : http://www.muehlheim.de/~skanthak/pgp/publickey.html

Lotto   : Taxes for people who are bad in maths

Re:How to add calculate field to Dbgrid


I've just started using Infopower's wwDBGrid, which allows calculated and
other table lookup's to be incorporated into a grid.

I dont work or get endorsed by them (woll2woll) but their product has saved
me months of work! :)  Their support (via email for me as I live in
Australia) is also excellent.

If you can afford it (I believe it was $325 Australian) get it!

Rabeh Mansour <khkha...@netvision.net.il> wrote in article
<01bc428b$659e6ce0$b0035ac2@mansour>...

Quote
> Hi

> I need the way or an example showing how to add a calculate field to the
> DbGrid.

> Thanks

Re:How to add calculate field to Dbgrid


Quote
"Boris Ingram" <boris...@iafrica.com> wrote:
>you need to add the field to the dataset tha provides data to the grid, not
>to the grid itself
>to do this use tdataset.fieldefs.add to add  a new field.Then set in code
>the appropriate properties, especially tfield.calculated/  You also need to
>add an oncalcfield event handler for the tdataset, which will fill the
>newly added field with data

This is what I do for calculated fields depending on the current data
row, but I does not work for cumulative fields, like a running total. If
you managed to make it work, how did you do it ?

-------------------------
   Frederic G. MARAND
  Agorus SA / OSI SARL
      f...@soon.com
-------------------------

Other Threads