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
Item ForeColor and sorting
Re: Item ForeColor and sorting
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
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!
Boycott DRM! Boycott HDCP!
Re: Item ForeColor and sorting
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 ?
regards;
Meelis
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 ?
regards;
Meelis
Re: Item ForeColor and sorting
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:Currenlty i sotore color info in itemData, but i dont know what if i want to use it for other information
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.Mex wrote:Maybe you can add a ForeColor property to ILIstItem ?
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!