TsListBox font color

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #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 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.