Einzelnen Beitrag anzeigen

s4sh81

Registriert seit: 11. Sep 2008
11 Beiträge
 
#3

AW: Stringgrid drucken

  Alt 22. Mai 2019, 18:31
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
Stringgrid1.ColWidths[0] := 75;
Stringgrid1.ColWidths[1] := 510;
Stringgrid1.ColWidths[2] := 50;
Stringgrid1.ColWidths[3] := 30;

  StringGrid1.colcount := 4;
  StringGrid1.rowcount := 60;
  StringGrid1.Cells [0,0] := 'Datum';
  StringGrid1.Cells [1,0] := 'Arbeitsbeschreibung';
  StringGrid1.Cells [2,0] := 'Stunden';
  Stringgrid1.Cells [3,0] := 'PKW';
  Stringgrid1.Cells [0,2] := datetostr(now);
  Stringgrid1.Cells [1,2] := 'Hallo, das ist ein test, ob eer auch einen zeilenumbruch hinbegkommet, und dann kommt jede menge text und text und text noch mehr text um zu testen ob der zeilenumbruch funktionerit';
  stringgrid1.Cells [3,2] := '15';
end;


procedure TForm1.Button4Click(Sender: TObject);
begin
if PrintDialog1.execute then
begin
  PrintStringGrid(stringGrid1, '', poPortrait);
end;
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
StringGrid1.Canvas.FillRect(Rect);
// Jetzt kommt was aus der WindowsAPI
DrawText(StringGrid1.Canvas.Handle,
PChar(StringGrid1.Cells[ACol, ARow]),
length(StringGrid1.Cells[ACol, ARow]),
Rect, DT_WordBreak)
end;

end.
  Mit Zitat antworten Zitat