Nadya Posted September 15, 2020 Share Posted September 15, 2020 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 More sharing options...
Sherzod Posted September 15, 2020 Share Posted September 15, 2020 1 hour ago, Nadya said: Is there any way to solve this problem or I should use additional components to display multi line grand total? Hello Nadya, Try use '<br>' instead of #13#10 1 Link to comment Share on other sites More sharing options...
Nadya Posted September 15, 2020 Author Share Posted September 15, 2020 11 minutes ago, Sherzod said: Hello Nadya, Try use '<br>' instead of #13#10 Wonderful, that's exactly what is needed!!! Thank you VERY much!! 1 Link to comment Share on other sites More sharing options...
Nadya Posted September 15, 2020 Author Share Posted September 15, 2020 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 More sharing options...
Sherzod Posted September 15, 2020 Share Posted September 15, 2020 23 minutes ago, Nadya said: ... Is the issue resolved? Link to comment Share on other sites More sharing options...
Nadya Posted September 15, 2020 Author Share Posted September 15, 2020 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 More sharing options...
Nadya Posted September 15, 2020 Author Share Posted September 15, 2020 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 More sharing options...
Nadya Posted September 15, 2020 Author Share Posted September 15, 2020 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!!! 1 Link to comment Share on other sites More sharing options...
Sherzod Posted September 15, 2020 Share Posted September 15, 2020 Yes. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now