Autor Beitrag
OliverN_26
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: Mo 03.01.11 02:36 
Hi Leute

Ist es möglich "1 Eintrag" in der ComboBox mehrfarbig zu gestalten?
Also NICHT die Zeile - das weiss ich.

also so:

ausblenden Delphi-Quelltext
1:
ComboBox1.Items.Strings[index] := 'Das[blau] ist[gelb] ein[rot] Test[grün].';					


Ich danke euch
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mo 03.01.11 02:43 
Jap, selber färben beim Zeichnen.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
OliverN_26 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: Mo 03.01.11 03:08 
Hi

Ich hab doch geschrieben dass ich weiss wie man "ZEILEN" färbt.
Ich weiss allerdings nicht wie man innerhalb "1 Zeile" die Farbe ändert.
Das bringt mich leider kein Stück weiter.

lg
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mo 03.01.11 03:48 
Da bist ja schon na dran, die Methode ist die gleiche:

Ersten Teil zeichnen, Font.Color wechseln, nächsten Teil, nochmal wechseln etc. Damit du weißt, wo es weiter geht, sollte man die X-Position z.B. per Addition von TextWidth mitzählen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
OliverN_26 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: Mo 03.01.11 16:33 
Ich danke dir :-) Das war der richtige Tip.
Hier mal der Code falls es jemanden interessieren sollte.

Zur Erläuterung: Ich habe einen Begriff und dann in Klammern einen Wert. Und dieser soll in eine andere Farbe.
Beispiel: Aufträge (21)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with ComboBox1, ComboBox1.Canvas do begin
    Font.Color  := clWhite;  // SchriftFarbe
    Brush.Color := clGreen;  // HintergrundFarbe
    FillRect(Rect);          // Hintergrund zeichnen
    TextOut(Rect.Left+2,Rect.Top+1,
            copy(Items[index],1,Pos('(',Items[index])-1)); // Textausgabe

    Font.Color  := clWhite;  // SchriftFarbe
    Brush.Color := clMaroon; // HintergrundFarbe
    TextOut(Rect.Left+2+TextWidth(copy(Items[index],1,Pos('(',Items[index])-1)),
            Rect.Top+1,copy(Items[index],Pos('(',Items[index]),
            Length(Items[index]))); // Textausgabe
  end;
end;


danke noch mal und ein frohes neues Jahr :-)