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

LVL 1
keithcslAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

florisbCommented:
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-).
0
kambizCommented:
After filling the rectangle, change the brush color to previous color of it.

I hope this helps you
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
keithcslAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.