Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: So 01.06.03 13:33 
Wie bekomme ich es hin, dass die Liste einer ComboBox eine andere Farbe hat als der Text?
user defined image

Erst, wenn ComboBox.Text<>'' ist, will ich die Farbe ändern.

_________________
Michael
(principal certified lotus professional - developer)
Terra23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 872

Win 8
Delphi 7
BeitragVerfasst: So 01.06.03 14:17 
Also bei mir kennt die CB die Eigenschaften "Color" und "Text" bzw. "ItemIndex" und das Ereignis "OnContextPopup". Eine Kombination von allem stelle ich mir so vor:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ComboBox1ContextPopup(Sender: TObject);
begin
If (ComboBox1.ItemIndex>0) Or (ComboBox1.Text<>'')
Then ComboBox1.Color:=clRed
Else ComboBox1.Color:=clWindow;
end;


Ich denke mal, so in etwa geht das. Ist aber nicht getestet, könnte Bugs haben... :-)

_________________
Hasta La Victoria Siempre
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: So 01.06.03 14:18 
Schau dich mal nach den PieTools um. Die haben eine Komponente, mit der das geht.
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: So 01.06.03 14:39 
@Terra23: So geht's nicht, da color für die gesammte Combobox gilt :? ...

@Onz: Irgendwelche Wald- und Wiesen-komponenten will ich nicht verwenden. Was weis ich, was dann wieder beim nächsten Releasewechsel von Delphi auf mich zukommt, wenn ich nur Kompos von "Pfefferminzia" im Einsatz habe und es die dann nicht mehr gibt...

_________________
Michael
(principal certified lotus professional - developer)
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: So 01.06.03 15:35 
hallo,

es gibt da ondrawitem als event
hier mal nen leicht modifizierter codeschnipsel aus meinem prog
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
begin
  with vcBox.Canvas do begin
    FillRect(Rect);
    if not irgendwas then
      Font.Color := clRed
    else
      Font.Color := clBlack;
    if odFocused in State then
      Font.Color :=  clHighlightText;
    Pen.Style := psClear;
    TextOut(Rect.Left, Rect.Top, cBox.Items[Index]);
  end;
end;


Dieser schnipsel malt alle items, auf die irgendwas zutrifft rot.

Gruß
Ken