RzTabbedListbox and lbOwnerDrawFixed

Home Forums Konopka Signature VCL Controls (formerly Raize Components) RzTabbedListbox and lbOwnerDrawFixed

Viewing 2 reply threads
  • Author
    Posts
    • #2899
      Peter Gustafsson
      Participant

        Hi

        Is it possible to use Style lbOwnerDrawFixed and use tabs?
        When I use this code to change item color my columns is removed. Colors works fine.

        with TRzTabbedListBox(Control) do
        begin

        LicenseInfo := Items[index];

        if ContainsText(LicenseInfo, ‘success’) then
        canvas.Font.Color := clLime;

        canvas.FillRect(Rect);
        canvas.TextOut(Rect.Left, Rect.Top, (Control as TRzTabbedListBox).Items[Index]);
        end;

        I guess canvas.TextOut remove the #9 from text. Is there a way to make it work?
        I need to change both item color and item background and still use tabs.

        Thanks.

      • #2900
        Ray Konopka
        Keymaster

          Hi Peter,

          The TRzTabbedListBox (well, the TRzCustomTabbedListBox) uses the TabbedTextOut method to display the tabbed contents of the list box. However, if you simply want to change the color of the text of a list box item, you can called the DefaultDrawItem method in the OnDrawItem event handler. For example,

          procedure TForm7.RzTabbedListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
          begin
            if not ( odSelected in State ) then
            begin
              if Index mod 2 = 0 then
                RzTabbedListBox1.Canvas.Font.Color := clRed
              else
                RzTabbedListBox1.Canvas.Font.Color := clBlue;
            end;
            RzTabbedListBox1.DefaultDrawItem( Index, Rect, State );
          end;

          This event handler colors the lines alternating colors. Since Index starts off at 0 for the listbox, the first item is colored red. The second is blue, and the third is back to red, etc. However, if the item is selected, then the font color is not changed so that the selected font color is used against the selection background color.

          Ray

        • #2901
          Peter Gustafsson
          Participant

            Hi Ray!

            Thanks for the help. I got it working just as I wanted. Both pretty colors and tabs. 🙂

            Peter

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.