Home › Forums › Konopka Signature VCL Controls (formerly Raize Components) › RzTabbedListbox and lbOwnerDrawFixed
Tagged: lbOwnerDrawFixed, TRzTabbedListBox
- This topic has 2 replies, 2 voices, and was last updated 2022-01-16 at 12:02 pm by
Peter Gustafsson.
-
AuthorPosts
-
-
January 15, 2022 at 11:21 am #2899
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
beginLicenseInfo := 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.
-
January 16, 2022 at 1:06 am #2900
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
-
January 16, 2022 at 12:02 pm #2901
Hi Ray!
Thanks for the help. I got it working just as I wanted. Both pretty colors and tabs. 🙂
Peter
-
-
AuthorPosts
- You must be logged in to reply to this topic.