Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Verschiedene Farben einzelner Items in ComboBox (https://www.delphipraxis.net/146940-verschiedene-farben-einzelner-items-combobox.html)

toms 1. Feb 2010 08:01

Re: Verschiedene Farben einzelner Items in ComboBox
 
Es genügt einmal (FindComponent(CB)) as TCombobox) aufzurufen anstatt 8 Mal (Wegen Übersicht, Geschwindigkeit, Redundanz etc.)

DeddyH 1. Feb 2010 10:11

Re: Verschiedene Farben einzelner Items in ComboBox
 
Und wegen Fehlertoleranz. Wenn FindComponent nichts findet, gibt das sonst einen dicken Crash.
Delphi-Quellcode:
procedure TMHauptmaske.ComboBoxDrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var holdColor: TColor;
     Combo: TCombobox;
begin
  Combo := FindComponent(CB) as TCombobox;
  if Assigned(Combo) then
    begin
      holdColor := Combo.Canvas.Brush.Color;
      DB.TSTSTATUS.Locate('BEZ',Combo.Items[index],[]);
      Combo.canvas.Brush.Color := stringtocolor(DB.TSTSTATUSFARBE.asstring);
      Combo.canvas.Font.Color := clblack;
      Combo.Canvas.FillRect(rect);
      Combo.Canvas.TextOut(Rect.left, Rect.top, Combo.Items[index]);
      Combo.canvas.brush.Color := holdColor;
    end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:09 Uhr.
Seite 2 von 2     12   

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