Question
“How do I line up the group footer bands when using multiple columns and the amount of records in each group is different?”
Solution
This can be done by copying the draw commands in the existing group footers then moving them to the proper position on the page lined up with the lowest group footer. Use the OnDrawCommandCreate event of the components inside the group footer to save them for each column. Then use the OnEndPage event of the report to line the components up with eachother.
Download: ColumnsWGroupFootersAligned.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
procedure TForm1.FormCreate(Sender: TObject); begin FFooter1DrawCommands := TList.Create; FFooter2DrawCommands := TList.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin FFooter1DrawCommands.Free; FFooter2DrawCommands.Free; end; procedure TForm1.ppReport1StartPage(Sender: TObject); begin // clear the draw command lists FFooter1DrawCommands.Clear; FFooter2DrawCommands.Clear; end; procedure TForm1.ppReport1EndPage(Sender: TObject); var liIndex: Integer; lDrawCommand1: TppDrawCommand; lDrawCommand2: TppDrawCommand; begin // align group footer draw commands for liIndex := 0 to FFooter1DrawCommands.Count-1 do begin lDrawCommand1 := TppDrawCommand(FFooter1DrawCommands[liIndex]); lDrawCommand2 := TppDrawCommand(FFooter2DrawCommands[liIndex]); // adjust to max top if lDrawCommand1.Top > lDrawCommand2.Top then lDrawCommand2.Top := lDrawCommand1.Top else lDrawCommand1.Top := lDrawCommand2.Top; end; end; procedure TForm1.GroupFooterDrawCommandCreate(Sender, aDrawCommand: TObject); begin // this event-handler is assigned to the OnDrawCommandCreate event of each // object in the group footer band // the event fires each time an object prints on a page. The aDrawCommand // parameter contains a TppDrawCommand descendant generated by the // Label, Shape, or DBText if ppReport1.CurrentColumn = 1 then FFooter1DrawCommands.Add(aDrawCommand) else FFooter2DrawCommands.Add(aDrawCommand) end; |