Item ForeColor and sorting

The place for threads about TimoSoft ExplorerListView.
Post Reply
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Item ForeColor and sorting

Post by Mex »

Hi Timo (again:))

My question is;
When i set in CustomDraw items TexColor, how to i preserve this color when user clicks column header and all items are sorted?
Lets say i first set items forecolor to blue. (item's index=100)
After sorting this item has index 1.
Must i every time set each items color programmatically or is there any other solution?

BR;
Meelis
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: Item ForeColor and sorting

Post by TiKu »

Hi,

CustomDraw cannot preserve such things, you have to set the colors and so on on each paint cycle. To make items always have the same text color even if the list view is sorted or items are inserted/removed, you could identify the items by their ID, because the ID won't change. Another approach is to use the ItemData property to store layout hints (which colors to use and so on) and read this ItemData property in CustomDraw event.

TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: Item ForeColor and sorting

Post by Mex »

Hi

Currenlty i sotore color info in itemData, but i dont know what if i want to use it for other information :)
Maybe you can add a ForeColor property to ILIstItem :P?


regards;
Meelis
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: Item ForeColor and sorting

Post by TiKu »

Mex wrote:Currenlty i sotore color info in itemData, but i dont know what if i want to use it for other information :)
Well, you can store all these things in a complex data structure and use ItemData to store a reference to the real data (e. g. the memory address or an array index).
Mex wrote:Maybe you can add a ForeColor property to ILIstItem :P?
I won't, because it's totally against how the native list view works and because text color is just one thing you can do with custom draw. If I add a per-item ForeColor property, the next one will ask why I don't add a per-item Font property, because this can be done via CustomDraw, too. Also while a per-item ForeColor property might be helpful, for you, it would be cumbersome in other situations.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Post Reply