Search code examples
delphidelphi-2007

DELPHI Table cell split & merge


How can I make something like this in Delphi:

Table

I know I can make it from 3 tables so it would be easier, but how can I make Table cells split & merge and how to get the text to turn 90deg.?

Is there some good content libraries that have split & merge built in?


Solution

  • Check out woll2woll or infopower. They will do the grid for sure. The font can be achieved by overriding the OnDrawDataCell, OnDrawGroupHeaderCell and OnDrawTitleCell events and writing the text with rotated font.

    {****************************************************************
    * Create angled font. Procedure writen by Keith Wood            *
    ****************************************************************}
    procedure CreateAngledFont (AFont : TFont; const AAngle : Integer);
    var
      FntLogRec: TLogFont { Storage area for font information } ;
    begin
      { Get the current font information. We only want to modify the angle }
      fillchar (FntLogRec, sizeof(FntLogRec), #0);
      GetObject (AFont.Handle, SizeOf(FntLogRec), Addr(FntLogRec));
    
      { Modify the angle. "The angle, in tenths of a degrees, between the   base
        line of a character and the x-axis." (Windows API Help file.) }
      FntLogRec.lfEscapement   := (AAngle * 10);
      FntLogRec.lfOrientation  := (AAngle * 10);
      FntLogRec.lfOutPrecision := OUT_TT_PRECIS;  { Request TrueType precision }
    
      { Delphi will handle the deallocation of the old font handle }
      AFont.Handle := CreateFontIndirect (FntLogRec);
    end;