Hallo,
ich möchte in einem DrawGrid eine bestimmte Zelle einfärben. Scheint einfach zu sein. Ich habe ein kleines Testprogramm gemacht, dass nacheinander alle Zellen einer Zeile rot färben soll, immer mit 500 ms Pause zwischen den einzelnen Zellen. 
In meinem Beispiel (Code unten und als Projekt im Anhang) geht das bis Spalte 3 wie geplant. Bei Spalte 4 wird nur noch eine schmale Linie gezeichnet und ab dann geht nichts mehr. Das Tabellenraster ist auf dem Monitor klar zu sehen.
Ein Breakpoint nach der Zeile "Rect := ..." zeigt, dass hier was falsch läuft:
Zeile 1: Rect = ( 0,102),(10,152): OK, Breite = 10, Hoehe=50
Zeile 2: Rect = (11,102),(21,152): OK
Zeile 3: Rect = (22,102),(32,152): OK
Zeile 4: Rect = (33,102),(32,152): FALSCH
Zeile 5: Rect = ( 0,  0),( 0,  0): FALSCH
Mache ich was falsch oder hat die Funktion da eine Macke? Hat jemand eine Idee? (Windows 10)
Grüße
GuaAck
												| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 
 | UNIT UGridfaerben2;
 INTERFACE
 
 USES
 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
 Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids;
 
 TYPE
 TForm1 = CLASS(TForm)
 DrawGrid1: TDrawGrid;
 Button1: TButton;
 PROCEDURE Button1Click(Sender: TObject);
 PRIVATE
 
 PUBLIC
 
 END;
 
 VAR
 Form1: TForm1;
 
 IMPLEMENTATION
 
 {$R *.dfm}
 
 PROCEDURE TForm1.Button1Click(Sender: TObject);
 VAR
 Breite, Hoehe: integer;
 Rect: TRect;
 Col, Row: integer;
 BEGIN
 Breite := 10;
 Hoehe := 3;
 DrawGrid1.FixedCols := 0;
 DrawGrid1.FixedRows := 0;
 DrawGrid1.DefaultColWidth := 10;
 DrawGrid1.DefaultRowHeight := 50;
 DrawGrid1.RowCount := Breite;
 DrawGrid1.ColCount := Hoehe;
 Row := 2;
 DrawGrid1.Canvas.Brush.Color := clred;
 FOR Col := 0 TO Breite - 1 DO
 BEGIN
 Rect := DrawGrid1.CellRect(Col, Row);
 DrawGrid1.Canvas.FillRect(Rect);
 sleep(500);
 END;
 END;
 
 END.
 | 
		
	  
Moderiert von  Th69: Titel leicht geändert.
Th69: Titel leicht geändert.