Ich seh' den Wald schon wieder vor lauter Bäumen nicht.
Ich habe eine Form mit zwei StringGrids.
Bei einem davon möchte ich die Schrift in der ersten Zeile um 90° drehen.
Mach ich es so:
Code: Alles auswählen
type
TStringGrid = class(Grids.TStringGrid)
protected
procedure DrawCellText(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState; AText: String); override;
end;
implementation
procedure TStringGrid.DrawCellText(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState; AText: String);
var TextPosition: TPoint;
begin
if aRow = 0 then
begin
Canvas.Font.Orientation := 900;
TextPosition.X := ARect.Left +
((ARect.Right - ARect.Left - Canvas.TextHeight(AText)) div 2) - 2;
TextPosition.Y := ARect.Bottom -
((ARect.Bottom - ARect.Top - Canvas.TextWidth(AText)) div 2);
Canvas.TextOut(TextPosition.X, TextPosition.Y, AText);
end
else
inherited DrawCellText(ACol, ARow, ARect, AState, AText);
end;
Mach ich es jedoch so (Und ändere den Typ von TStringGrid1 auf TMyStringGrid (sowohl im QuellCode als auch in der *.lfm-Datei)):
Code: Alles auswählen
type
TMyStringGrid = class(Grids.TStringGrid)
protected
procedure DrawCellText(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState; AText: String); override;
end;
implementation
procedure TMyStringGrid.DrawCellText(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState; AText: String);
var TextPosition: TPoint;
begin
if aRow = 0 then
begin
Canvas.Font.Orientation := 900;
TextPosition.X := ARect.Left +
((ARect.Right - ARect.Left - Canvas.TextHeight(AText)) div 2) - 2;
TextPosition.Y := ARect.Bottom -
((ARect.Bottom - ARect.Top - Canvas.TextWidth(AText)) div 2);
Canvas.TextOut(TextPosition.X, TextPosition.Y, AText);
end
else
inherited DrawCellText(ACol, ARow, ARect, AState, AText);
end;
Bitte um den entscheidenden Rippenstoß
Christian