Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   onDrawColumnCell in DelphiXE2 (https://www.delphipraxis.net/172799-ondrawcolumncell-delphixe2.html)

mcbain 23. Jan 2013 13:32

onDrawColumnCell in DelphiXE2
 
Hallo,

ich initialisiere in onCreate ein 2 Dimensionales Array folgendermaßen:

Code:
 
type
TZelle = (zFrei, zBesetzt);
...
FGrid: array[0..200,0..32] of TZelle;
....
 for i := 0 to 200 do
  begin
    for j := 0 to 32 do
    begin
      FGrid[i][j]:= zFrei;
    end;
  end;

  FGrid[17][2] := zBesetzt;
in der OnDrawColumnCell eines DBGrids mache ich dann folgendes:

Code:
...
var rec : TRect;
  zeile : Integer;
  zelle: TZelle;
begin
  rec := Rect;

  with (Sender as TDBGrid) do
  begin
    zeile := DataSource.DataSet.RecNo;
    zelle := FGrid[zeile][DataCol];

    if (not (gdSelected in State) and(DataCol <> 0)) then
    begin
       if zelle = zBesetzt then
       begin
         Canvas.Brush.Color := clRed;
         Canvas.FillRect(rec);
       end;  

    end;
    Canvas.TextOut(rec.Left + 2, rec.Top + 1, Column.Field.AsString); //Denn Text in der Zelle ausgeben
  end;
Ich möchte also spezielle Felder des DBGrids anders einfärben. Welche eingefärbt werden sollen, kommen aus dem array FGrid.
Leider wird in diesem Beispiel nicht nur die Zelle[17,2] eingefärbt, sondern auch noch 2 weitere Zellen.

Kann mir jemand sagen, woran das liegen könnte?
Vielen Dank.
gruß
mc


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:26 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz