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. C#
  4. Show sort header arrow and image in listview 2.0

Show sort header arrow and image in listview 2.0

Scheduled Pinned Locked Moved C#
helpquestioncode-review
5 Posts 3 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.
  • I Offline
    I Offline
    ika2
    wrote on last edited by
    #1

    Hi... In my application I have some listviews. I wanted to improve their appeareance adding an image to the headers. This is easy using smallimagelist of the listview class. The problem is that I want to show the sort arrow. For this I do it in this way: IntPtr hHeader = Win32.SendMessage(this.Handle,Win32.LVM_GETHEADER,IntPtr.Zero,IntPtr.Zero); . . (more code) . . . Win32.SendMessage2(hHeader,Win32.HDM_SETITEM,new IntPtr(columnIndex),ref hd); But when I click a header, the images dissapears. Does anybody know a solution for this issue? thanks

    N 1 Reply Last reply
    0
    • I ika2

      Hi... In my application I have some listviews. I wanted to improve their appeareance adding an image to the headers. This is easy using smallimagelist of the listview class. The problem is that I want to show the sort arrow. For this I do it in this way: IntPtr hHeader = Win32.SendMessage(this.Handle,Win32.LVM_GETHEADER,IntPtr.Zero,IntPtr.Zero); . . (more code) . . . Win32.SendMessage2(hHeader,Win32.HDM_SETITEM,new IntPtr(columnIndex),ref hd); But when I click a header, the images dissapears. Does anybody know a solution for this issue? thanks

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Hello I assume you are using dllImport to send that message to your header cell. Why?? You can use myList.Columns[X].ImageIndex to show the arrow in your imagelist and change the arrow image in the ColumnClick event. Anyway, if you still want to use messages, try to resend the message in the click event handler. PS. What is Win32.SendMessage?? Where do you put the above code? Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?

      Regards:rose:

      I A 2 Replies Last reply
      0
      • N Nader Elshehabi

        Hello I assume you are using dllImport to send that message to your header cell. Why?? You can use myList.Columns[X].ImageIndex to show the arrow in your imagelist and change the arrow image in the ColumnClick event. Anyway, if you still want to use messages, try to resend the message in the click event handler. PS. What is Win32.SendMessage?? Where do you put the above code? Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?

        Regards:rose:

        I Offline
        I Offline
        ika2
        wrote on last edited by
        #3

        Of course, I´m using dllimport and I handled the ColumClick event. Win32 is only a class that hosts dllimports and other stuff. I know I can use ImageIndex to show the arrow. But... what I want is...to show an image and the arrow, at the same time. What I want is something like this: http://www.codeproject.com/cs/miscctrl/XPTable.asp. But with listview 2.0. kind regards and thanks for your answer

        N 1 Reply Last reply
        0
        • N Nader Elshehabi

          Hello I assume you are using dllImport to send that message to your header cell. Why?? You can use myList.Columns[X].ImageIndex to show the arrow in your imagelist and change the arrow image in the ColumnClick event. Anyway, if you still want to use messages, try to resend the message in the click event handler. PS. What is Win32.SendMessage?? Where do you put the above code? Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?

          Regards:rose:

          A Offline
          A Offline
          Arjun Mjolnir Bahree
          wrote on last edited by
          #4

          Using the native sending of messages is uncalled for here. It is vanishing because the same init is not being persisted. You need to couple creation message with every other message, if you insist in sending antive messages. Though i can see two more ways of achieving the same result, though from unmanaged apps.

          Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!

          1 Reply Last reply
          0
          • I ika2

            Of course, I´m using dllimport and I handled the ColumClick event. Win32 is only a class that hosts dllimports and other stuff. I know I can use ImageIndex to show the arrow. But... what I want is...to show an image and the arrow, at the same time. What I want is something like this: http://www.codeproject.com/cs/miscctrl/XPTable.asp. But with listview 2.0. kind regards and thanks for your answer

            N Offline
            N Offline
            Nader Elshehabi
            wrote on last edited by
            #5

            Hello Well, one easier solution is: 1- Get the image from your ImageList; 2- Use a Graphics object to draw the arrow with the proper direction at the proper place of the image. 3- Show the image in your header!! This way you won't need to use unmanaged calls!!

            Regards:rose:

            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