Solved

Tabbed List Box Colors

Posted on 2002-05-15
1
174 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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

12 Experts available now in Live!

Get 1:1 Help Now