![]() |
Aktuelle Zeile in StringGrid farblich hervorheben
Hi @all!
Hat jemand eine Idee, wie ich die aktuelle makierte Zeile in einem StringGrid farblich hervorheben kann? Auf HILFE hoffend, Chris |
Schau dir mal das OnDraw Ereginis an.
Gruß |
Kleine Verbesserung: OnDrawCell
|
Hast natürlich recht.
|
Ja, habe ich mir angesehen. Sieht so aus:
Code:
Hat jemand vielleicht einen Source?
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); begin end; Chris |
Der Code hier ist zwar nicht direkt auf dein Problem bezogen, zechnet aber eine bestimmte Zeile in einer anderen Farbe:
Code:
var Grid: TStringGrid;
begin Grid := Sender as TStringGrid; if gdSelected in State then Grid.Canvas.Font.Color := clBlack; if ARow + 1 = DayOfTheWeek(Now) then begin Grid.Canvas.Brush.Color := RGB(255, 200, 200); Grid.Canvas.Font.Style := [fsBold]; end else Grid.Canvas.Brush.Color := Grid.Color; Grid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Grid.Cells[ACol, ARow]); end; |
@jbg: Erstmal danke, aber leider klappt das nicht so ganz... *sniff*
Chris |
Zitat:
Aber hier hast du einen für dich passenden Code:
Code:
Jetzt musst du nur noch die Farben anpassen.
var Grid: TStringGrid;
begin Grid := Sender as TStringGrid; if gdSelected in State then begin Grid.Canvas.Font.Color := clBlack; Grid.Canvas.Brush.Color := RGB(200, 200, 255); Grid.Canvas.Font.Style := [fsBold]; end else Grid.Canvas.Brush.Color := Grid.Color; Grid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Grid.Cells[ACol, ARow]); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:09 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