Solved

Tabbed List Box Colors

Posted on 2002-05-15
1
176 Views
Last Modified: 2010-04-04
I have a program that I use Tabbed List Boxes in.
What I would like to do is to get different items in one box to have multiple colors / fonts.

How can I get this to work?

0
Comment
Question by:accurates
1 Comment
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 7012703
i dont know ,im guessing this is like normal listbox so just set style to ownerdraw and add some code:

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
 i : integer;
begin
  if Odd(Index) then
     i := clRed
  else
     i := clYellow;
  TListBox(Control).Canvas.Brush.Color := i;
  if NOT Odd(Index) then
     i := clRed
  else
     i := clYellow;
  TListBox(Control).Canvas.Font.Color := i;
  TListBox(Control).Canvas.TextRect(Rect, Rect.Left, Rect.Top,
     ListBox1.Items.Strings[Index]);
end;

basically if the component has ownderdraw style then you have access to all canvas and fonts brushes/pens colors styles etc..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now