Adding Images to ListView Subitems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Doggett

    Adding Images to ListView Subitems

    Hi

    I have a listview control with four columns. The problem
    I have is that the second column needs to display an
    image but as it is a subitem this doesn't appear to be
    able to be done. Does anyone have any suggestions.

    Thanks
  • Jeffrey Tan[MSFT]

    #2
    RE: Adding Images to ListView Subitems


    Hi Mark,

    Thanks for posting in this group.
    For your question, I think there is not a suitable property for you to set
    image to the listview subitem.
    I think you should do the owner draw yourself.
    While .Net does not expose the function for you to customize owner draw,
    you have to P/invoke the Win32 way of handling owner draw.
    When owner draw happens, there will be WM_NOTIFY with NM_CUSTOMDRAW sent.
    You should hook this message, and the message's lParam points to the
    NMLVCUSTOMDRAW structure(can be find in platform sdk document). You can
    check its iSubItem field, to do cutomize owner draw to certain subitem.

    Hope this helps,

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.

    --------------------
    | Content-Class: urn:content-classes:message
    | From: "Mark Doggett" <mark.doggett@w aymaker.co.uk>
    | Sender: "Mark Doggett" <mark.doggett@w aymaker.co.uk>
    | Subject: Adding Images to ListView Subitems
    | Date: Tue, 11 Nov 2003 07:37:07 -0800
    | Lines: 8
    | Message-ID: <554101c3a869$a a492a60$7d02280 a@phx.gbl>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="iso-8859-1"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    | Thread-Index: AcOoaapJo8/IZV2nTiq/P4ybFDcjdw==
    | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    | Path: cpmsftngxa06.ph x.gbl
    | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1983 88
    | NNTP-Posting-Host: TK2MSFTNGXS01 10.40.2.125
    | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
    |
    | Hi
    |
    | I have a listview control with four columns. The problem
    | I have is that the second column needs to display an
    | image but as it is a subitem this doesn't appear to be
    | able to be done. Does anyone have any suggestions.
    |
    | Thanks
    |

    Comment

    Working...