How to refresh a wx.ListCtrl image?

I have a wx.ListCtrl with a unique 16x16 icon for the first column’s item of each row.
Using SetItem to change the text programmatically works fine.

However, when I change one of these icons by adding a new bitmap to the associated wx.ImageList and calling SetItemColumnImage(row, 0, image_index), the image does not change. Nor does it change when I use SetItem and pass the image_index.

I’ve tried calling RefreshItem(index), Refresh(), and Update(), but none of these works.

Since you’re adding a new image then you probably also need to redo the SetImageList. On Windows, for example, it gets converted to a native image list and passed to a Windows API, rather than accessing the images directly in the wx.ImageList.

CORRECTION: The wxImageList is a (wrapper around a) native Windows image list, so it’s not actually creating a new native list in SetImageList. But I think that calling SetImageList is still needed in this case, as that is where the native listctrl is informed about the image list details.

I’ve just tried that on both Linux & Windows but it doesn’t help.

Ok. Please make a small runnable sample that demonstrates the problem and I’ll dig a little deeper.

I think the problem is that I’m going against the grain of how wx.ListCtrl is supposed to be used with icons so instead of a unique one per item I’ll just have one or two.