Einzelnen Beitrag anzeigen

Robert_G
(Gast)

n/a Beiträge
 
#4

Re: TStringGrid Textüberlappend

  Alt 4. Nov 2003, 14:49
Ich hab´s doch noch raus gefunden.



Mit dem dem Code kann man eine Zelle auf die gesamte Breite des Grids erweitern.
(ähnlich wie "merge cells" in Excel)

Delphi-Quellcode:
procedure TRule_Form.OutGridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
   i,y,x:integer;
begin

  If aCol = 0 Then Exit;
  If gdFixed In State Then Exit;
  If OutGrid.Cells[0,arow] <> 'MessageThen exit;
  with sender as tstringgrid do begin

  // Komplette Zeile mit dem Text von Spalte 1 füllen
    If aCol < Pred(ColCount) Then
      Rect.Right := Rect.Right + GridlineWidth;

    y:= Rect.Top + 2;
    x:= Rect.Left + 2;
    for i:= 1 to aCol-1 do
      x:= x - ColWidths[i] - GridlineWidth;

    { Paint Zellenhintergrund weiß}
    Canvas.Brush.Color := $FFFFFF;
    Canvas.Brush.Style := bsSolid;
    Canvas.FillRect( Rect );

    Canvas.TextRect( Rect, x, y, Cells[1,arow] );
  end;

end;
  Mit Zitat antworten Zitat