Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: VCL / WinForms / Controls (https://www.delphipraxis.net/24-library-vcl-winforms-controls/)
-   -   Delphi Text in StringGrid Cell zentriert ausrichten (https://www.delphipraxis.net/7946-text-stringgrid-cell-zentriert-ausrichten.html)

Tpercon 25. Aug 2003 09:45


Text in StringGrid Cell zentriert ausrichten
 
Durch das folgende DrawCell Ereignis wird jede einzeilige Texteingabe im StringGrid zentriert ausgerichtet.
Delphi-Quellcode:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  s: string;
begin
  s := StringGrid1.Cells[ACol, ARow]; // Text der Zelle holen
  StringGrid1.Canvas.FillRect(Rect); // Zelle leer überzeichnen
  DrawText(StringGrid1.Canvas.Handle, PChar(s), Length(s), Rect, DT_SINGLELINE or DT_Center or DT_VCENTER); // Text zentriert zeichnen
end;
[edit=Matze] Mfg, Matze[/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:58 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz