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