Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Listbox mit Farbflächendarstellung (https://www.delphipraxis.net/194721-listbox-mit-farbflaechendarstellung.html)

to-wer 29. Dez 2017 19:58

AW: Listbox mit Farbflächendarstellung
 
Du bist genial... es geht.
Jetzt verstehe ich langsam diese Prozedur, wo "Index" ja auch in der Variablenübergabe auftaucht...

Hier noch einmal die ganze Prozedur, falls sie jemand anderem noch helfen kann.
Delphi-Quellcode:
procedure TForm2.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TComboBox).Canvas do begin // in ComboBox zeichnen
    Brush.Color := StringToColor(Stringarray[Index]); //im Stringarray befinden sich die HEX-Farbwerte
    Brush.Style := bsSolid;
    FillRect(Rect);
    Brush.Style := bsClear;
    TextOut(Rect.Left, Rect.Top, (Control as TComboBox).Items[Index]);
  end;
end;

Aviator 29. Dez 2017 19:58

AW: Listbox mit Farbflächendarstellung
 
Zitat:

Zitat von Delphi.Narium (Beitrag 1389841)
Wenn man diese Zeile ändert

Delphi-Quellcode:
Brush.Color := StringToColor(Polyneon[ComboBox1.ItemIndex]);


in

Delphi-Quellcode:
Brush.Color := StringToColor(Polyneon[Index]);


werden die Farben beim Aufklappen (wie gestern schon vermutet) korrekt angezeigt.

Es soll ja schließlich die Farbe zum entsprechenden Eintrag aus Polyneon und nicht immer die Farbe des zufällig gerade gewählten Eintrages genommen werden.

:thumb::thumb::thumb:

Sowas übersieht man dann auch leicht in dem geposteten SourceCode auf Seite 1 :stupid:


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:58 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz