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. ListViewItem image overlay [modified]

ListViewItem image overlay [modified]

Scheduled Pinned Locked Moved C#
graphicsdesigntutorialquestion
3 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.
  • A Offline
    A Offline
    ajtunbridge
    wrote on last edited by
    #1

    Hi all. I'm trying to create a custom ListView where I can display an overlay image over an item. Basically, I'm creating a simple document management system and I want to be able to mark a document as obsolete or locked and then display an image over the documents' icon to inform the user. I've never really delved into UI programming before and I'm not too sure how to go about it. I've started off with a class derived from ListView, I've set the OwnerDraw property to true and subscribed to the DrawItem event. Where do I go from here? Edit: By the way, I've sussed out the drawing of the items image, it's only the text I'm having trouble with. I've got this so far

      if (this.View != View.Details)
      {
        if ((e.State & ListViewItemStates.Selected) != 0)
          e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordBreak);
        else
          e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.EndEllipsis);
      }
    

    However, when I select an item, the text populates the whole of the items bounds. I want it to extend down past the item as it does in explorer.

    modified on Wednesday, June 18, 2008 9:34 AM

    L 1 Reply Last reply
    0
    • A ajtunbridge

      Hi all. I'm trying to create a custom ListView where I can display an overlay image over an item. Basically, I'm creating a simple document management system and I want to be able to mark a document as obsolete or locked and then display an image over the documents' icon to inform the user. I've never really delved into UI programming before and I'm not too sure how to go about it. I've started off with a class derived from ListView, I've set the OwnerDraw property to true and subscribed to the DrawItem event. Where do I go from here? Edit: By the way, I've sussed out the drawing of the items image, it's only the text I'm having trouble with. I've got this so far

        if (this.View != View.Details)
        {
          if ((e.State & ListViewItemStates.Selected) != 0)
            e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordBreak);
          else
            e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.EndEllipsis);
        }
      

      However, when I select an item, the text populates the whole of the items bounds. I want it to extend down past the item as it does in explorer.

      modified on Wednesday, June 18, 2008 9:34 AM

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      I am totally confused by your post. Why don't you just change the image of the item rather than do an OwnerDraw control?

      led mike

      A 1 Reply Last reply
      0
      • L led mike

        I am totally confused by your post. Why don't you just change the image of the item rather than do an OwnerDraw control?

        led mike

        A Offline
        A Offline
        ajtunbridge
        wrote on last edited by
        #3

        I was going to do that (retrieve the file types' icon and then just add my image to it) but I've never played with OwnerDraw before and thought I'd give it a go. This is only a personal project so I've got the time to learn a few new bits.

        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