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/)
-   -   Delphi DBGRID Hintergrund einer Zelle ändern (https://www.delphipraxis.net/25947-dbgrid-hintergrund-einer-zelle-aendern.html)

Berserker 15. Jul 2004 12:29


DBGRID Hintergrund einer Zelle ändern
 
Hallo Delphi-Geminde.

Ich habe mal ein Anliegen zum DBGRID.
Ich habe eine Funktion, welche mit immer eine Zeile komplett einfärbt.
Nun möchte ich aber z.B. wenn ein Datensatz in einem Feld ACTIVE den Wert 1 hat, im DBGRid das angezeigte Feld Preis mit Gelben Hintergrund einfärben. Eine komplette Zeile Färben geht. Nur das eine Feld habe ich bis jetzt nicht hinbekommen.

Kann mir jemand weiterhelfen?

Viele Grüße Ronny

Berserker 15. Jul 2004 12:35

Re: DBGRID Hintergrund einer Zelle ändern
 
Hallo nochmal.

Problem ist gelöst. :roll:

Sharky 15. Jul 2004 12:38

Re: DBGRID Hintergrund einer Zelle ändern
 
Hai Berseker,

guckst Du:
Delphi-Quellcode:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if (Column.Field.FullName = 'ACTIVE') then
  begin
    if (Column.Field.AsInteger = 1) then
    begin
      DBGrid1.Canvas.Brush.Color := clYellow;
    end;
  end;
  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State)
end;
:cry: Zu langsam

Berserker 15. Jul 2004 13:09

Re: DBGRID Hintergrund einer Zelle ändern
 
Hoi.

Was ich gesucht habe ist in Prinzip das, nur das die Spalte, welche das Feld ACTIVE enthält nicht im Grid ist.

Delphi-Quellcode:
procedure Tmainform.grdARTIKELDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);

begin
 if (gdSelected in State) or (gdFocused in State) then exit;
 with sender as TDBGrid do begin
  if(tblARTIKEL.FieldByName('flagACTIVE').AsInteger=1) then begin
   if(column.fieldname='preis') then begin
    canvas.Font.Color := clBlack;
    canvas.Brush.Color := clYellow;
    canvas.fillrect (rect);
   end;
  end;
 end;
 grdARTIKEL.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:08 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