![]() |
tStringgrid und Zeilenfärben --> Verzweiflung
Hallo zusammen,
ich hab 'n stringgrid und eine routine (hier aus dem forum) um die zeilen zu färben, aber der macht einfach nix... :gruebel: habt ihr eine ahnung an was es liegen könnt? Zitat:
Delphi-Quellcode:
bin für jede Hilfe dankbar.
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids; type TForm1 = class(TForm) sg: TStringGrid; procedure sgDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin inherited; if not Odd(ARow) then begin Canvas.Brush.Color := clWebMintcream; Canvas.FillRect(Rect); Canvas.TextOut(Rect.Left+2, Rect.Top+2, (sender as tstringgrid).Cells[ACol, ARow]); end; end; |
Re: tStringgrid und Zeilenfärben --> Verzweiflung
Überleg Dir mal, auf wessen Canvas Du zeichnest ;)
Delphi-Quellcode:
procedure TForm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); begin inherited; if not Odd(ARow) then begin sg.Canvas.Brush.Color := clRed; //clWebMintCream kennt mein Delphi nicht sg.Canvas.FillRect(Rect); sg.Canvas.TextOut(Rect.Left+2, Rect.Top+2, (sender as tstringgrid).Cells[ACol, ARow]); end; end; |
Re: tStringgrid und Zeilenfärben --> Verzweiflung
hallo deddyh,
danke für die antwort, aber vielleicht hätte ich noch mit dazusagen sollen, dass acol und arow immer den gleichen wert, nämlich 0, haben. keine ahnung warum... dank und gruss und noch 'n schönen sonntag |
Re: tStringgrid und Zeilenfärben --> Verzweiflung
Zitat:
Also entweder 2ten Monitor zulegen, Programm in VM ausführen oder dafür sorgen das IDE-Fenster dein Grid nicht verdecken. |
Re: tStringgrid und Zeilenfärben --> Verzweiflung
ups, danke, war wohl etwas zu voreilig. das war es :-) :cheers: :cheers:
Delphi-Quellcode:
procedure TForm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); begin inherited; with (sender as tStringGrid) do if Odd(ARow) then begin Canvas.Brush.Color := clWebMintcream; Canvas.FillRect(Rect); Canvas.TextOut(Rect.Left+2, Rect.Top+2, (sender as tstringgrid).Cells[ACol, ARow]); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14: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-2025 by Thomas Breitkreuz