Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Icon In ListView Header .Net

Icon In ListView Header .Net

Scheduled Pinned Locked Moved Visual Basic
csharp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lespaul36
    wrote on last edited by
    #1

    I have been trying to get my listview to show an icon on the right side of the header if that column has been clicked. So far I have had almost no luck. Any links to one would be great. Showing code would be good too. I know I had found one once, but I can not find it again. Thanks

    L 1 Reply Last reply
    0
    • L lespaul36

      I have been trying to get my listview to show an icon on the right side of the header if that column has been clicked. So far I have had almost no luck. Any links to one would be great. Showing code would be good too. I know I had found one once, but I can not find it again. Thanks

      L Offline
      L Offline
      lespaul36
      wrote on last edited by
      #2

      I have this code that I found, but I keep getting a Nullreference error. Declarations Private Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" _ (ByVal hwnd As IntPtr, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As HD_ITEM) As Long Const LVM_FIRST = &H1000 Const LVM_GETHEADER = (LVM_FIRST + 31) Const HDI_BITMAP = &H10 Const HDI_IMAGE = &H20 Const HDI_FORMAT = &H4 Private Const HDI_TEXT = &H2 Private Const HDF_BITMAP_ON_RIGHT = &H1000 Private Const HDF_BITMAP = &H2000 Private Const HDF_IMAGE = &H800 Private Const HDF_STRING = &H4000 Private Const HDM_FIRST = &H1200 Private Const HDM_SETITEM = (HDM_FIRST + 4) Private Const HDM_SETIMAGELIST = (HDM_FIRST + 8) Private Const HDM_GETIMAGELIST = (HDM_FIRST + 9) Private Structure HD_ITEM Dim mask As Integer Dim cxy As Integer Dim pszText As String Dim hbm As Integer Dim cchTextMax As Integer Dim fmt As Integer Dim lParam As Integer Dim iImage As Integer Dim iOrder As Integer End Structure Dim hHeader As IntPtr = ShellDll.SendMessage(lstView.Handle, Win32.WindowsMessages.LVM_GETHEADER, 0, 0) Dim lvImage As IntPtr = ShellDll.SendMessage(hHeader, Win32.WindowsMessages.HDM_SETIMAGELIST, 0, CInt(Me.imgArrows.Handle.ToInt32)) Dim lret As IntPtr For i As Integer = 0 To lstView.Columns.Count - 1 'Use the LVM_SETCOLUMN message to set the column's image index. Dim HD As New HD_ITEM Dim pblnAlignRight As Boolean With HD .mask = HDI_IMAGE Or HDI_FORMAT .pszText = lstView.Columns(i).Text End With If lstView.Columns(i).TextAlign = HorizontalAlignment.Right Then pblnAlignRight = True Else pblnAlignRight = False End If If i = ColumnIndex Then With HD .fmt = HDF_STRING Or HDF_IMAGE Or HDF_BITMAP_ON_RIGHT .iImage = IconIndex End With Else HD.fmt = HDF_STRING End If SendMessage(hHeader, HDM_SETITEM, i, HD)'error occurs here Next

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups