ListView header icons do not show-up

S.Br.

Board Regular
Joined
Oct 5, 2012
Messages
95
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2011
  5. 2010
  6. 2007
Dear Mr. Excel; please take a look at the following script and tell me
why my column header icons do not show up:

VBA Code:
' Microsoft Windows [Version 10.0.19045.5608]
' Microsoft® Excel® for Microsoft 365 MSO (Version 2502 Build 16.0.18526.20144) 64-bit
' Microsoft Visual Basic for Applications 7.1 Version 1146
' List View ActiveX Control - Version 6.0 (SP6)
' Image List ActiveX Control - Version 6.0 (SP6)

Option Explicit

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
  ' List View ActiveX Control - Version 6.0 (SP6)
  With ColumnHeader
    If .Icon = 0 Then
      .Icon = .Index
    Else
      .Icon = 0
    End If
  End With
End Sub

Private Sub UserForm_Initialize()
  With ImageList1
    .ImageHeight = 12
    .ImageWidth = 12
    With .ListImages
      .Clear
      .Add Picture:=LoadPicture(ThisWorkbook.Path & Application.PathSeparator & "img1.bmp")
      .Add Picture:=LoadPicture(ThisWorkbook.Path & Application.PathSeparator & "img2.bmp")
    End With
  End With
  With ListView1
    Set .ColumnHeaderIcons = ImageList1
    With .ColumnHeaders
      .Clear
      .Add Text:="HDR1", Icon:=1
      .Add Text:="HDR2", Icon:=2
    End With
    With .ListItems
      .Clear
      With .Add(Text:="ITEM1")
        .ListSubItems.Add Text:="subitem1"
      End With
      With .Add(Text:="ITEM2")
        .ListSubItems.Add Text:="subitem2"
      End With
    End With
  End With
End Sub
All I've put on the UserForm is just 2 controls: ImageList1 and ListView1. Many thanks in advance,
S.Br.
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top