TAdvStringGrid
Example 42 : merged cell printing

An example makes this more clear:
Suppose the grid is sorted alphabetically on car brand and a secondary sort on the number of cylinders. First, the MergeColumnCells is applied as a main merged column for the column that contains the car brand name. After this, the column with number of cylinders need to be merged. It is very likely that succesive cells for 4 cylinders belong to different car brand names. With a MergeColumnCells(cylindercolumn, True) call, these cells with identical cylinders would be merged irrespective of the car brand these belong to. With the call MergeColumnCells(cylindercolumn, False), the merged car brand name column is taken into account and only rows within a merged row block of the car brand will be merged in the cylinder column.
Further this project demonstrates the use of bitmap resources and automatic picture creation. A resource file holds several bitmaps representing the car brand logos. After applying the merge, the correct bitmap is created for the base cell only of the merged car brand cell block with :
AdvStringGrid.CreateBitmap(ACol,ARow,True,haCenter,vaAboveText).LoadFromResourceName(hinstance, CarBrandName);
It takes no further effort to print this grid. Simply calling grid.Print will print the grid as displayed on screen.
Delphi project & source files for downloading included in the main demos distribution for Delphi.
×