Board index » delphi » Changing row color of a listview?

Changing row color of a listview?

Hi,
I change the color of desired rows in a listview using OnCustomDrawItem
with the below code
(does OnDrawItem work the same way? I tried to use that event but
nothing happened?)

   if (Item..... = .....) then
      ListView.Canvas.Brush.Color := myColor;

it works. But after a short while the exe (on Win98 SE) on clients
crashes. I traced the application with Memproof. There were traces of
hundreds of 'CreateFontIndirect()' ptr's. They dissappear when I delete
the code from the OnCustomDrawItem event. I couldn't manage to change
the color without memory leaks and crashes.
Does anybody have a solution to this problem

thanx,
bora aydemir

 

Re:Changing row color of a listview?


Quote
Bora Aydemir wrote:
> Hi,
> I change the color of desired rows in a listview using OnCustomDrawItem
> with the below code
> (does OnDrawItem work the same way? I tried to use that event but
> nothing happened?)

>    if (Item..... = .....) then
>       ListView.Canvas.Brush.Color := myColor;

> it works. But after a short while the exe (on Win98 SE) on clients
> crashes. I traced the application with Memproof. There were traces of
> hundreds of 'CreateFontIndirect()' ptr's. They dissappear when I delete
> the code from the OnCustomDrawItem event. I couldn't manage to change
> the color without memory leaks and crashes.
> Does anybody have a solution to this problem

> thanx,
> bora aydemir

Use OnDrawItem to change the way TListView is drawing. You must set the
OwnerDraw property to true. Otherwise OnDrawItem isn't called.

Other Threads