Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview Color by line 1

Status
Not open for further replies.

Fluke026

Programmer
Aug 20, 2002
32
0
0
US
Hello,

This problem is probably very easy to solve, but the solution is eluding me. Is there any way to set the background or font color of each item in a listview individually?

I have a ListView component on a form displaying data from instances of a class. The only problem is that I want to change the color of certain lines depending on a variable from the instance. There are three possibilities:

Code:
if (instance meets cond1) then
   DisplayData on black background
else if (instance meets cond2) then
   DisplayData on grey background
else DisplayData on white background

The three condition sets are mutually exclusive.

How can I change the color for that line and only that line? I will also accept changing the font color for that line only.

Thank you,
Frank
 
Fluke,

I dont think you can set the color of individual items.
I think you will have to implement the OnDrawItemEvent,
and adjust the Background/FontColor of the Canvas there depending on the state of the item,
and after that draw the (text of the) item yourself...

Hope this Helps

- fruNNik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top