Link to home
Start Free TrialLog in
Avatar of keithcsl
keithcsl

asked on

TListView Color...

Hi all

i have a list view with 2 columns, "Color" and "Name"...

I want to put one color for each row in the Color column. For a start, I have tried adding this in the onOwnerDraw:

  ListView.Canvas.Brush.Color := clGreen;
  ListView.Canvas.FillRect (Rect(0,0,2,2));

I thought this will fill a little box at the top left hand corner, but it
filled up the entire row. How do I solve this?

Keith

Avatar of florisb
florisb

If I drop a listview on a form and add a button where I put the two of your code lines, it does fill only a little box at the left top corner.

Try a testproject with just a listview and your code, because it's correct.

F-).
ASKER CERTIFIED SOLUTION
Avatar of kambiz
kambiz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keithcsl

ASKER

hei guys

i found the problem. first, i did not change the color back. but then, found that after coloring the canvas, the add item routine recolors it back to white.

it's getting too complicated. i have decided to abandon this method.

however, kambiz gave the right solution, so i am accepting that.

PS: i am posting another similar question.

Keith