![]() |
Probleme mit ComboBox-Einträge in verschiedenen Farben
Hallo,
ich möchte gerne in meiner Combobox, Einträge in verschieden Schriftfarben angezeigt bekommen. so ungefähr items[0]= Blau items[1]= Rot in einem ähnlichen beitrag habe ich bereits ein Code Beispiel gefunden. Doch er funktioniert bei mir nicht. Gibt es irgentwelche Besonderheiten, Einstellungen usw. zu beachten? Vielleicht ist es nur ein Versionskonflikt. Ich programmiere mit Delphi7.
Delphi-Quellcode:
Bin für alle Ideen und Vorschläge offen.
procedure TfrmMAIN.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState); var cb : TComboBox; begin cb := TComboBox(Control); case Index of 0 : begin cb.Canvas.Brush.Color := clWhite; cb.Canvas.FillRect(Rect); cb.Canvas.Font.Color := clBlack; cb.Canvas.TextOut(Rect.Left,Rect.Top,cb.Items[Index]); end; 1 : begin cb.Canvas.Brush.Color := clGreen; cb.Canvas.FillRect(Rect); cb.Canvas.Font.Color := clWhite; cb.Canvas.TextOut(Rect.Left,Rect.Top,cb.Items[Index]); end; 2 : begin cb.Canvas.Brush.Color := clRed; cb.Canvas.FillRect(Rect); cb.Canvas.Font.Color := clWhite; cb.Canvas.TextOut(Rect.Left,Rect.Top,cb.Items[Index]); end; end; end Danke! Cathleen |
Re: Probleme mit ComboBox-Einträge in verschiedenen Farben
:hi:
Hast Du "Style" auch entsprechend geändert? mfg Tobias |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:09 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