Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.153 Beiträge
 
Delphi 12 Athens
 
#8

Re: Verschiedene Farben einzelner Items in ComboBox

  Alt 30. Jan 2010, 11:23
Jetzt noch statt combobox1 ein TComboBox(Control) verwenden und es ist perfekt.

Zitat:
Delphi-Quellcode:
if combobox1.Items.Strings[index] = 'test1then
  combobox1.canvas.Brush.Color := clred;
if combobox1.Items.Strings[index] = 'test2then
  combobox1.canvas.Brush.Color := clyellow;
if combobox1.Items.Strings[index] = 'test3then
  combobox1.canvas.Brush.Color := clgreen;
Wenn du weißt, welcher Eintrag wo ist, dann kannst du den Index auch direkt verwenden.
Delphi-Quellcode:
case Index of
  0: TComboBox(Control).Canvas.Brush.Color := clRed;
  1: TComboBox(Control).Canvas.Brush.Color := clYellow;
  2: TComboBox(Control).Canvas.Brush.Color := clGreen;
end;

PS: Eine ordentliche Codeeinrückung, sowie eine entsprechende Groß-/Kleinschreibung macht das Lesen/Verstehen von Code um Einiges einfacher.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat