AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

StringGrid Inhalte zentrieren.

Ein Thema von Piro · begonnen am 2. Dez 2003 · letzter Beitrag vom 27. Jun 2011
Antwort Antwort
madtom

Registriert seit: 24. Feb 2005
Ort: Hamburg
115 Beiträge
 
Delphi XE7 Professional
 
#1

AW: StringGrid Inhalte zentrieren.

  Alt 27. Jun 2011, 22:46
Hier noch ein Beispiel dazu von Peter Below (TeamB)

Delphi-Quellcode:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; nCol, nRow: Longint; nRect: TRect;
  State: TGridDrawState);
var
  Cpos: Integer;
begin
  with (Sender as TStringGrid) do
    with Canvas do
    begin
      Font := (Sender as TStringGrid).Font;

      if (gdSelected in State) and (Sender = ActiveControl) then
      begin
        Brush.Color := clHighlight;
        Font.Color := clHighlightText;
      end
      else if (gdFixed in State) then
        Brush.Color := (Sender as TStringGrid).FixedColor
      else
        Brush.Color := (Sender as TStringGrid).Color;
      FillRect(nRect);
      SetBkMode(Handle, TRANSPARENT);

      if (nRow = 0) or (nCol = 2) then
      { Centered Text }
      begin
        SetTextAlign(Handle, TA_CENTER);
        with nRect do
          Cpos := Left + ((Right - Left) div 2) - 1;
        TextOut(Cpos, nRect.Top + 2, Cells[nCol, nRow]);
      end
      else if (nCol = 3) or (nCol = 4) then
      { Right Justified Text }
      begin
        SetTextAlign(Handle, TA_Right);
        TextOut(nRect.Right - 2, nRect.Top + 2, Cells[nCol, nRow]);
      end
      else
      begin
        { normal Left Justified Text }
        SetTextAlign(Handle, TA_LEFT);
        TextOut(nRect.Left + 2, nRect.Top + 2, Cells[nCol, nRow]);
      end;
    end;
end;
Gruß madtom
Thomas
Delphi Programming
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:05 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz