Jump to content

Is it possible to make DBGrid summary grand total multiline?


Nadya

Recommended Posts

Hello!

My DBGrid contains columns with positive and negative values.

I need to calculate 3 summary grand total values for every column - positive, negative and common summary (positive + negative).

For this separate calculation I use Column.AuxValues[1], Column.AuxValues[2] and Column.AuxValues[3] in OnColumnSummary and OnColumnSummaryTotal events.

OnColumnSummary:

        //positive
        if Column.Field.Value > 0
        then
            Column.AuxValues[1] := Column.AuxValues[1] + Column.Field.Value; 
        //negative
        if Column.Field.Value < 0
        then
            Column.AuxValues[2] := Column.AuxValues[2] + Column.Field.Value;   
        //total
        Column.AuxValues[3] := Column.AuxValues[1] + Column.AuxValues[2];

It works fine.

In OnColumnSummaryTotal event I would like to display this grand total values in 3 lines for every column:

        Result := FormatFloat('##0.00', Column.AuxValues[1]) + #13#10 +
            FormatFloat('##0.00', Column.AuxValues[2]) + #13#10 +
            FormatFloat('##0.00', Column.AuxValues[3]);

But it doesn't work, grand total row doesn't support text wrap and auto height. I can't place this values in 1 line because column will be too wide.

Is there any way to solve this problem or I should use additional components to display multi line grand total?

Thank you in advance for any advice!

Link to comment
Share on other sites

And one more question about grand total summary - why OnColumnSummary and OnColumnSummaryTotal events doesn't work for text column?

I would like to place into grand total record (under text column "Name") this text: "Positive" + '<br>' + "Negative" + '<br>' + "Total"

But when I debug - this code doesn't work for my "Name" column

It's not allowed for text columns or maybe I've set some properties wrong?

Oh, if matters - my DBGrig has disabled Grouping

Link to comment
Share on other sites

21 minutes ago, Sherzod said:

Is the issue resolved?

For numeric columns - it's all right (after replacing #13#10 by '<br>').

But for text column - no.

I would like to place into grand total (under string column "Name") this text: "Positive" + '<br>' + "Negative" + '<br>' + "Total"

But it doesn't work and when I debug - debugger doesn't enter the code fragment for "Name" column (string datatype).

OnColumnSummary and OnColumnSummaryTotal event are not allowed for text columns? Or maybe I've set some properties wrong?

Link to comment
Share on other sites

I'd like to make my grand total look like this:

Name             Sum1        Sum2
-------------------------------------
SomeText1   -100           300
SomeText2     200          -700
============================(grand total row)
Negative       -100        -700
Positive          200          300
Total               100        -400

============================(grand total row)

Link to comment
Share on other sites

2 hours ago, Nadya said:

I would like to place into grand total (under string column "Name") this text: "Positive" + '<br>' + "Negative" + '<br>' + "Total"

But it doesn't work and when I debug - debugger doesn't enter the code fragment for "Name" column (string datatype).

OnColumnSummary and OnColumnSummaryTotal event are not allowed for text columns? Or maybe I've set some properties wrong?

Ooops! I've found the reason - for column "Name" property ShowSummary = False was set.

Problem solved. Thanks for help!!!

  • Upvote 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...