Board index » delphi » Total fields in DBGrid?

Total fields in DBGrid?

Greetings!

I am wondering if anyone has come up with an easy way to create a totals
line in a DBGrid component.  The only way I can get it to provide totals
is by placing another DBGrid and using an additional query to gather the
totals.

Ideally, if the DBGrid component allowed a footer where totals of the
columns could be placed it would be perfect.

Any ideas would be appreciated...

Alan Sisson

 

Re:Total fields in DBGrid?


On Tue, 07 Jul 1998 22:31:10 -0600, Alan Sisson <asis...@novatel.ca>
wrote:

Quote
>Greetings!

>I am wondering if anyone has come up with an easy way to create a totals
>line in a DBGrid component.  The only way I can get it to provide totals
>is by placing another DBGrid and using an additional query to gather the
>totals.

>Ideally, if the DBGrid component allowed a footer where totals of the
>columns could be placed it would be perfect.

>Any ideas would be appreciated...

>Alan Sisson

What I've usually done (though it looks different than what you want)
is to put the grid on a form and under the appropriate columns of the
grid, on the form, I've put TLabels which I use to display the totals.
If you use the grid in data-aware mode, then each row corresponds with
a record in the database so there won't be a record to associate with
the total. You can write your own code to use a non-data aware grid
which won't be too hard if you aren't allowing updates or edits. You
could then add the row in code.

Steve F (Team B)

Re:Total fields in DBGrid?


Hi,
You can override the paint methode of your TDBGrid.
I do this and i put a CountOnParent property. if the parent is a TGroupBox
or a TTabsheet
i add on the caption the number of records in getting the
Datasource.DataSet.recordCount.
That works !

Fred B  FRANCE

Alan Sisson a crit dans le message <35A2F60E.1...@novatel.ca>...

Quote
>Greetings!

>I am wondering if anyone has come up with an easy way to create a totals
>line in a DBGrid component.  The only way I can get it to provide totals
>is by placing another DBGrid and using an additional query to gather the
>totals.

>Ideally, if the DBGrid component allowed a footer where totals of the
>columns could be placed it would be perfect.

>Any ideas would be appreciated...

>Alan Sisson

Other Threads