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. ListView Icon Selection

ListView Icon Selection

Scheduled Pinned Locked Moved C#
question
5 Posts 2 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.
  • J Offline
    J Offline
    Jonathan Austin
    wrote on last edited by
    #1

    Hello, I have a ListView that is set in Details mode for the view. It has no headers though that's likely irrevalent. I have a SmallImageList set and I set an icon for a ListViewItem. When an Item is selected, it also highlights the icon on the left. How would I stop it from highlighting it? I know that I could catch the WM_PAINT but then would I have to repaint the whole control? Is there something that I'm missing? Thanks, Jonathan

    J 1 Reply Last reply
    0
    • J Jonathan Austin

      Hello, I have a ListView that is set in Details mode for the view. It has no headers though that's likely irrevalent. I have a SmallImageList set and I set an icon for a ListViewItem. When an Item is selected, it also highlights the icon on the left. How would I stop it from highlighting it? I know that I could catch the WM_PAINT but then would I have to repaint the whole control? Is there something that I'm missing? Thanks, Jonathan

      J Offline
      J Offline
      Jonathan Austin
      wrote on last edited by
      #2

      Ok. This was a bad question. The standard ListView does not highlight the icon. I am trying to modify the TreeListView that was posted on CodeProject and it does highlight the icon using a ListView. I will have to investigate more.

      J 1 Reply Last reply
      0
      • J Jonathan Austin

        Ok. This was a bad question. The standard ListView does not highlight the icon. I am trying to modify the TreeListView that was posted on CodeProject and it does highlight the icon using a ListView. I will have to investigate more.

        J Offline
        J Offline
        Jonathan Austin
        wrote on last edited by
        #3

        It appears that I butchered my question. I still have the original question. When I went back and look at my other example, the icon I was looking at just didn't show the highlight as bad. Therefore, does anyone know the answer to my question? Thanks, Jonathan

        J 1 Reply Last reply
        0
        • J Jonathan Austin

          It appears that I butchered my question. I still have the original question. When I went back and look at my other example, the icon I was looking at just didn't show the highlight as bad. Therefore, does anyone know the answer to my question? Thanks, Jonathan

          J Offline
          J Offline
          Jeff J
          wrote on last edited by
          #4

          Highliting the icon is handled automatically by listviews, and there is no style bit or anything to override that behaviour. I also wish only the text were highlited, but to do so would mean custom drawing, as you mentioned. I have done it, but that code is somewhere in the archives of a company I once worked for. If you still desire to do so, the drawing of the foreground and background colors is fairly easy, but handling the drawing of the focus rectangle is a bit of a pain (at least when multi-select is enabled). Be careful when drawing selection ranges, as you need to remember which item is the "pivotal" selection (I forget the official term, it's been a while). Othewise, you won't be able to extend or reverse selection changes properly, when the user keeps CTRL or SHIFT down.

          J 1 Reply Last reply
          0
          • J Jeff J

            Highliting the icon is handled automatically by listviews, and there is no style bit or anything to override that behaviour. I also wish only the text were highlited, but to do so would mean custom drawing, as you mentioned. I have done it, but that code is somewhere in the archives of a company I once worked for. If you still desire to do so, the drawing of the foreground and background colors is fairly easy, but handling the drawing of the focus rectangle is a bit of a pain (at least when multi-select is enabled). Be careful when drawing selection ranges, as you need to remember which item is the "pivotal" selection (I forget the official term, it's been a while). Othewise, you won't be able to extend or reverse selection changes properly, when the user keeps CTRL or SHIFT down.

            J Offline
            J Offline
            Jonathan Austin
            wrote on last edited by
            #5

            Thank you for your response. I have been looking at some of Carols Perez's great work here on CodeProject where he does a lot of customdraw listviews and treeviews. It gets pretty complicated as you have to receive all of the correct messages and such. It looks like I'm going to just let it go for now and I may change it a little later. Custom control Drawing does not appear to be one of my strong points. :) Jonathan

            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