![]() |
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 |
Re: DBGRID Hintergrund einer Zelle ändern
Hallo nochmal.
Problem ist gelöst. :roll: |
Re: DBGRID Hintergrund einer Zelle ändern
Hai Berseker,
guckst Du:
Delphi-Quellcode:
:cry: Zu langsam
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; |
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 08:13 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