![]() |
TDBGrid - OnDrawColumnCell - Multiselect funktioniert nicht
Code:
Folgendes Problem:
procedure TfrmQuali.grdQLeistungenDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var farbe : tcolor; begin with (Sender as TDBGrid), Canvas do begin farbe := clwindow; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'E' then farbe := clwindow; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'K' then farbe := $000674E1; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'L' then farbe := clsilver; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'N' then farbe := $0001D2F8; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'Q' then farbe := $0071AE78; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'N/A' then farbe := clred; if erstesauslesenQ then begin Font.Color := clWindowtext; brush.Color := farbe; if column.Index = 9 then erstesauslesenQ := false; end else begin if (gdselected in state) then begin Font.Color := clHighlightText; Brush.Color := clActiveCaption; end else begin font.Color := clwindowtext; Brush.Color:= farbe; end; end; Fillrect(rect); DefaultDrawColumnCell(rect, DataCol, Column, State); end; end; Bei einem DBGrid ohne OnDrawColumnCell-Ereignis funktioniert ein Multiselect ohne weitere Probleme. Bei meiner obig verwendeten Variante (die für die Farbgebung notwendig ist) zeichnet er die Zeile in den SelectedRows nicht mehr in der Markiert-Farbe. Hat jemand alternative Vorschläge wie man dieses Problem lösen könnte, oder wie ich feststelle ob die aktuelle Zeile in den Selectedrows enthalten ist, ohne den aktuellen fokus zu verlieren? Danke Freaggle P.S.: gdselect ist wohl nur bei aktuellem Fokus im State enthalten |
Re: TDBGrid - OnDrawColumnCell - Multiselect funktioniert ni
peinlich, hat sich erledigt:
Code:
procedure TfrmQuali.grdQLeistungenDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var farbe : tcolor; begin with (Sender as TDBGrid), Canvas do begin farbe := clwindow; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'E' then farbe := clwindow; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'K' then farbe := $000674E1; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'L' then farbe := clsilver; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'N' then farbe := $0001D2F8; if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'Q' then farbe := $0071AE78; //if dmContainer.sqlQualiL.FieldByName('qs_status').AsString = 'N/A' then farbe := clred; if erstesauslesenQ then begin Font.Color := clWindowtext; brush.Color := farbe; if column.Index = 9 then erstesauslesenQ := false; end else begin if SelectedRows.CurrentRowSelected then begin Canvas.Brush.Color := clActiveCaption; Canvas.Font.Color := clHighlightText; end else {if (gdselected in state) then begin Font.Color := clHighlightText; Brush.Color := clActiveCaption; end else } begin font.Color := clwindowtext; Brush.Color:= farbe; end; end; Fillrect(rect); DefaultDrawColumnCell(rect, DataCol, Column, State); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:49 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