Einzelnen Beitrag anzeigen

Benutzerbild von Wolfgang Mix
Wolfgang Mix

Registriert seit: 13. Mai 2009
Ort: Lübeck
1.222 Beiträge
 
Delphi 2005 Personal
 
#7

AW: StringGrid Inhalte zentrieren.

  Alt 26. Jun 2011, 13:52
Vlt. kannst du das hier umstricken:

Delphi-Quellcode:
//http://www.delphi-forum.de
//procedure WriteTextAligned und
//procedure TForm1.StringGrid1DrawCell
procedure WriteTextAligned(Canvas: TCanvas; Rect: TRect; Alignment: TAlignment; Text: string);
var xPos, yPos: integer;
begin
xPos := Rect.Left + 2; // Standard verhalten
yPos := Rect.Top + 2; // Standard verhalten
with Canvas do
  begin
    xPos := Rect.Left + (Rect.Right - Rect.Left - TextWidth(Text) - 2);
    TextRect(Rect, xPos, yPos, Text);
  end;
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
          Rect: TRect; State: TGridDrawState);
begin
  // Alle Spalten rechtsbündig
  WriteTextAligned(TStringGrid(Sender).Canvas, Rect, taRightJustify, TStringGrid(Sender).Cells[Acol, ARow]);
end;
[Edit]

http://www.delphi-forum.de/topic_Text+im+StringGrid+rechtsbuendig+ausrichten_ 6188,0.html

[/Edit]
Wolfgang Mix
if you can't explain it simply you don't understand it well enough - A. Einstein
Mein Baby:http://www.epubli.de/shop/buch/Grund...41818516/52824

Geändert von Wolfgang Mix (26. Jun 2011 um 14:49 Uhr)
  Mit Zitat antworten Zitat