I don't seem to get any errors if I call SetItemText(item,subItem,string)
, on a value of subItem greater than the number of columns set up. But I don't seem to be getting the data back when I call GetItemText. Just wanted to check that's correct, and I can't use SetItemText as a more convenient way to add some custom data - SetItemData requires you remember to deallocate memory and so on.
views:
201answers:
2
+1
A:
I think you'll have to resort to the SetItemData
method although you seem to be afraid of the memory allocation/deallocation.
Why don't you override the CListCtrl
class with your own class (e.g. CMyListCtrl
) in which you implement e.g. a SetItemCustomData
method and which handles all the memory issues for you, so you don't have to deal with that in your actual user interface code?
fretje
2009-12-04 13:37:17
You also need to override methods used when an item is removed, of course. This is clearly the 'correct' answer but in this case what I actually did (because it made things very much neater in the code) was to add a zero-width column... I didn't prevent the column being resized as it might be useful to see the data sometime, but I could have done.
John
2009-12-07 09:01:37
A:
Did you check that you can get the text back?
Even if it works, I would absolutely avoid this kind of solution: You can't predict if it will still work in the next version of Windows. Or even if it worked in all the previous ones.
Use SetItemData()... and don't forget to free the memory!
Serge - appTranslator
2009-12-06 16:54:45