none
Image on Listview Subitem RRS feed

  • Question

  • Hello Dears

    Please I confess I'm a little bit frustrated.

    I'm trying to show a images/Icons in listview subitem, exactly as I did on Visual Basic 6 and VBA and I don't believe Visual Basic .NET haven't it. I found a lot of ways in Internet but using more complex methods with Windows API, Windows SendMenssages...

    Please, My experience tell me should exist a simple method to do it.

    Someone can help me..

    Thanks

    Saturday, May 27, 2017 2:19 AM

All replies

  • Hello Dears

    Please I confess I'm a little bit frustrated.

    I'm trying to show a images/Icons in listview subitem, exactly as I did on Visual Basic 6 and VBA and I don't believe Visual Basic .NET haven't it. I found a lot of ways in Internet but using more complex methods with Windows API, Windows SendMenssages...

    Please, My experience tell me should exist a simple method to do it.

    Someone can help me..

    Thanks

    You said that you want to show an image for a subitem? Do you mean item instead?

    With a listview, actually they're the same, truth be known, but have a look around this site and Google and you'll see lots of examples.

    I don't have any examples but you'll need an ImageList and using that, you can then reference which image to use based on the index. At least I think that's what I remember. ;-)

    Lastly, have a look at the documentation:

    https://msdn.microsoft.com/en-us/library/system.windows.forms.listview(v=vs.110).aspx

    Scroll down to where you'll see "Remarks" and that explains it.

    I hope this helps. :)


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Saturday, May 27, 2017 3:47 PM
  •  What images do you want to display in a SubItem,  icons of files you are listing or some separate images that you have on the hard drive or maybe in the resources?  Is there a reason you want them shown in a SubItem column instead of the Item column?

     There are different ways depending on how the items and images are being added to the ListView and if it is an Item or SubItem column you want to show them in.  So,  more details would help us to explain or show examples of the best ways to do it.

     One way would be to use an ImageList as Frank mentioned and setting the DisplayIndex of the first column to the index of the column you want the Image and ListViewItem text in.  That may require reworking your code though being that it is the ListViewItem`s column you are moving instead of actually displaying the image in a SubItem of the ListViewItem.

     If it is actually a SubItem you want to do this for,  there is not a setting or property you can just change for that.  It would require setting the ListView`s OwnerDraw property to True and handling drawing the ListView yourself.  It is not all that hard though,  i have shown 2 or 3 different examples of drawing images in SubItems using this method in the links below.

    VB.Net Display Image In Listview Subitems With Details Setting...

    how to draw image to subitem in listview in VB ?


    If you say it can`t be done then i`ll try it

    Saturday, May 27, 2017 7:23 PM