ListView Header Icon

L

Lespaul36

I want to put an Icon on the right side of a column header when the column
is clicked I found some basic code that I am trying to use, but nothing so
far.

Public Sub ShowHeaderIcon(ByVal colNo As Long, _
ByVal imgIconNo As Long, _
ByVal showImage As Long)

Dim hHeader As IntPtr
Dim HD As HD_ITEM

'get a handle to the listview header component
hHeader = SendMessage(listview1.Handle, LVM_GETHEADER, 0, 0)

'set up the required structure members
With HD
.mask = HDI_IMAGE Or HDI_FORMAT
.pszText = listview1.Columns(colNo).Text
If showImage Then
.fmt = HDF_STRING Or HDF_IMAGE Or HDF_BITMAP_ON_RIGHT
.iImage = imgIconNo
Else
.fmt = HDF_STRING
End If
End With

'modify the header

Call SendMessage(hHeader, HDM_SETITEM, colNo, HD)
 
K

Ken Tucker [MVP]

Hi,

There is an example in this sample on the code project website

http://www.codeproject.com/vb/net/ExpCombo.asp

Ken
----------------------
I want to put an Icon on the right side of a column header when the column
is clicked I found some basic code that I am trying to use, but nothing so
far.

Public Sub ShowHeaderIcon(ByVal colNo As Long, _
ByVal imgIconNo As Long, _
ByVal showImage As Long)

Dim hHeader As IntPtr
Dim HD As HD_ITEM

'get a handle to the listview header component
hHeader = SendMessage(listview1.Handle, LVM_GETHEADER, 0, 0)

'set up the required structure members
With HD
.mask = HDI_IMAGE Or HDI_FORMAT
.pszText = listview1.Columns(colNo).Text
If showImage Then
.fmt = HDF_STRING Or HDF_IMAGE Or HDF_BITMAP_ON_RIGHT
.iImage = imgIconNo
Else
.fmt = HDF_STRING
End If
End With

'modify the header

Call SendMessage(hHeader, HDM_SETITEM, colNo, HD)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top