TsListBox font color

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38292
    Jin
    Participant

    Hi, how to change font color of TsListBox if this TsListBox has skinmanager?

    #59638
    Support
    Keymaster

    Hi

    You can do it in the OnDrawItem event. Example of code:

    Code:
    procedure TForm1.AlertListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
    var
    OldColor: TColor;
    begin
    with AlertList.Canvas do begin
    OldColor := Font.Color;
    case Index of
    0: Font.Color := clGreen;
    1: Font.Color := clRed
    else Font.Color := clAqua;
    end;
    FillRect(Rect);
    TextOut(Rect.Left, Rect.Top, AlertList.Items[Index]);
    Font.Color := OldColor;
    end;
    end;

    AlertList is the TsListBox here.

    #59640
    Stephane Senecal
    Participant

    If you want the same color for the whole list use SkinData.CustomFont := True and set the color in the font as usual.

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.