![]() |
Re: Listbox färbt komisch ein
Zitat:
und: wenn ich mit der maus klicke werden die farben dargestellt. jedoch nicht beim laden der listbox bzw. beim laden des forms. wie kann ich die listbox IMMER farbig halten? |
Re: Listbox färbt komisch ein
Delphi-Quellcode:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState); begin with (Control as TListBox) do begin if Index = 2 then begin //bei best. Zeile soll folgendes gelten Canvas.Brush.Color := clRed; Canvas.Font.Color := clYellow; end else //falls gewünscht Canvas.Pen.Color := clyellow; if (odSelected in State) then begin Canvas.Font.Color := clHighlightText; Canvas.Brush.Color := clHighlight; end; Canvas.FillRect(Rect); Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, Items[Index]); end; end; Zitat:
Delphi-Quellcode:
Sobald sich der Wert ändert, musst du die Listbox neu zeichnen lassen. z.B per ListBox1.Repaint
if Index = 2 then
|
Re: Listbox färbt komisch ein
Zitat:
Delphi-Quellcode:
die Aktuelle Prozedur sieht so aus. Ich reagiere auf Settings in einem Ini-File. Wenn ich den listbox1.repaint beim Laden der Listbox einfüge (am Schluss) wird diese aber nicht korrekt farblich markiert...
procedure Tmainform.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState); begin with (Control as TListBox) do begin if getinivaluefrom(inttostr(listbox1.itemindex+1),'Active',getinivalue('StandardValues','TaskFile'))='false' then //bei best. Zeile soll folgendes gelten begin Canvas.Brush.Color := clRed; Canvas.Pen.Color := clWhite; end else begin //falls gewünscht Canvas.Brush.Color := clWhite; Canvas.Pen.Color := clBlack; end; if (odSelected in State) then begin Canvas.Font.Color := clHighlightText; Canvas.Brush.Color := clHighlight; end else Canvas.Font.Color := clWindowText; Canvas.FillRect(Rect); Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, Items[Index]); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:04 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