Dear Mr. Excel; please take a look at the following script and tell me
why my column header icons do not show up:
All I've put on the UserForm is just 2 controls: ImageList1 and ListView1. Many thanks in advance,
S.Br.
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
S.Br.