Putting images in headers of ListCtrl column

I am trying to put an image in the header of a list control column -- and no
where else. The demonstration puts images in the header and in the first
column. I assumed that if I used InsertStringItem rather than
InsertImageStringItem I would get only a string. However, as shown in the
attached program, I get an image in the list items even with
InsertStringItem if I have previously called SetImageList (which must be
called to get the image in the header). Is this the expected behavior for
InsertStringItem?

I found that using -1 as the image index in InsertImageStringItem suppresses
the image, but there is still a space where the image would appear.

Purging the image from the image list also suppresses the image but leaves a
space.

I even tried inserting the same item that I used for the column header. It
does not insert an image in the header, but it does in the list.

I don't see a way to unset the image list. It seems that once image list is
set, something is going to appear (an image or a space) whether you call
InsertImageStringItem or InsertStringItem.

wx-test9.py (2.98 KB)

···

--
Jeffrey Barish

Jeffrey Barish wrote:

I am trying to put an image in the header of a list control column -- and no
where else. The demonstration puts images in the header and in the first
column. I assumed that if I used InsertStringItem rather than
InsertImageStringItem I would get only a string. However, as shown in the
attached program, I get an image in the list items even with
InsertStringItem if I have previously called SetImageList (which must be
called to get the image in the header). Is this the expected behavior for
InsertStringItem?

That's a bug that has already been fixed for the next release.

I found that using -1 as the image index in InsertImageStringItem suppresses
the image, but there is still a space where the image would appear.

This is normal. The native ListView control on Windows assumes that if there is an image list then the items are going to have images and so it makes room for them. On way to work around this is to put no text in the column zero, and then resize col zero to zero width. Then the text that you normally would have put in col zero you should move over to col 1, and also shift over the other columns.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!