Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2635
  • Last Modified:

Add image to subitem in listview

How to add multiple images to one subitem in a listview in vb.net ?

I tried http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21645885.html?sfQueryTermInfo=1+10+imag+listview+two+vb.net, but it did not work. Using that code, only the first column has image and all subitems do not have any.

Thank you,

Jose Roberto
0
jr_barros_jr
Asked:
jr_barros_jr
  • 10
  • 5
  • 4
  • +1
1 Solution
 
SStoryCommented:
I've never seen a listview in detail mode that had subitems with images.
Have you?
0
 
Thunder724Commented:
it was something very easy in vb 6.0; but there is no easy way of doing it .net. I have seen some custome controls that will do this however.
0
 
Bob LearnedCommented:
I could think of a way, but I am curious how easy it was in VB6 (I have been away far too long)?  
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
SStoryCommented:
I didn't even know it was possible.  So I am also curious.  If it is possible then I would imagine that the dotnet ListView control is a wrapper for the one that is provided to Windows.  That one can do anything and one could probably access it with a lot of nasty code of a replacement...

I found this:
http://vbnet.mvps.org/index.html?code/comctl/index.html

If that worked in vb6, maybe it will work in DOTNET except that API declarations have to be written for dotnet...example dotnet Integer would be what VB6 considers a LONG.
0
 
Bob LearnedCommented:
@SStory
That is a long list.  Which specific reference are you talking about?
0
 
SStoryCommented:
Sorry. I don't know why the link didn't work unless it is all on the same page.

I was talking about the one titled "SendMessage: ListView Subitem Icons"

It seems to be related to subitem icons and subclassing with windows messages and such. I thought it might be helpful.
0
 
SStoryCommented:
Here is an article on doing that. It seems to use OakControls. I don't know if that is free or not:
http://www.codeproject.com/KB/list/OAKListView.aspx
0
 
jr_barros_jrAuthor Commented:
@SStory

I do not know if "Error List" window is a list view or not, but I would like to have that. If it is not a list view, would you know how can we have/do it?

Thank you.
0
 
SStoryCommented:
If you are talking about "Error List" from Visual Studio IDE, my error list only shows and icon in the first column.  That is easily doable.

That Error List is a combination of controls... listview, toolbar, panel, etc.
0
 
Bob LearnedCommented:
I don't see where any code was setting LVM_SETEXTENDEDLISTVIEWSTYLE.

Source:
http://www.codeproject.com/KB/list/listviewxp.aspx
Public Class ListViewEx
    Inherits System.Windows.Forms.ListView
 
   Private Const LVM_FIRST As Integer = &H1000
   Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Integer = (LVM_FIRST + 54)
   Private Const LVM_GETEXTENDEDLISTVIEWSTYLE As Integer = (LVM_FIRST + 55)
   Private Const LVS_EX_GRIDLINES As Integer = &H1 
   Private Const LVS_EX_SUBITEMIMAGES As Integer = &H2 
   Private Const LVS_EX_CHECKBOXES As Integer = &H4 
   Private Const LVS_EX_TRACKSELECT As Integer = &H8 
   Private Const LVS_EX_HEADERDRAGDROP As Integer = &H10 
   Private Const LVS_EX_FULLROWSELECT As Integer = &H20 
   Private Const LVS_EX_ONECLICKACTIVATE As Integer = &H40 
   Private Const LVS_EX_TWOCLICKACTIVATE As Integer = &H80 
   Private Const LVS_EX_FLATSB As Integer = &H100 
   Private Const LVS_EX_REGIONAL As Integer = &H200 
   Private Const LVS_EX_INFOTIP As Integer = &H400 
   Private Const LVS_EX_UNDERLINEHOT As Integer = &H800 
   Private Const LVS_EX_UNDERLINECOLD As Integer = &H1000 
   Private Const LVS_EX_MULTIWORKAREAS As Integer = &H2000 
   Private Const LVS_EX_LABELTIP As Integer = &H4000 
   Private Const LVS_EX_BORDERSELECT As Integer = &H8000 
   Private Const LVS_EX_DOUBLEBUFFER As Integer = &H10000 
   Private Const LVS_EX_HIDELABELS As Integer = &H20000 
   Private Const LVS_EX_SINGLEROW As Integer = &H40000 
   Private Const LVS_EX_SNAPTOGRID As Integer = &H80000 
   Private Const LVS_EX_SIMPLESELECT As Integer = &H100000 
 
   Public Sub SetExStyles() 
      Dim styles As LVS_EX = SendMessage(Me.Handle, LVM.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
      styles = styles Or LVS_EX_DOUBLEBUFFER Or LVS_EX.LVS_EX_BORDERSELECT 
      SendMessage(Me.Handle, CInt(LVM_SETEXTENDEDLISTVIEWSTYLE), 0, styles) 
   End Sub 
 
End Class

Open in new window

0
 
jr_barros_jrAuthor Commented:
@TheLearnedOne:

What is your code? Is a solution?
0
 
jr_barros_jrAuthor Commented:
@SStory:

Your are correct. My mistake. I meant Outlook e-mails. You can have Flag, Unread/read icon message etc.
0
 
Bob LearnedCommented:
I took an article, came up with a ListView that set the LVM_SETEXTENDEDLISTVIEWSTYLE, but is by no means a complete solution.  It is more food-for-thought...the hint was taken from the VB6 code, and some found on CodeProject...
0
 
SStoryCommented:
TheLearnedOne,
I don't see that either, but his sample code works for me.

jr_barros_jr,
If you download the sample program it does run.  I don't know why it runs without the message mentioned by TheLearnedOne, but it does work.  Is it trivial?  Not really.
El programa si funciona. Si se baja el ejemplo vera que funciona. No estoy seguro porque
0
 
jr_barros_jrAuthor Commented:
@SStory,

I just downloaded the code. I just have icons/pictures on the first column. The others columns do NOT have any picture, even after the click on the button.
0
 
SStoryCommented:
I downloaded the demo and ran it. I clicked the button and it worked fine.  That is strange.
What OS are you running on?
0
 
SStoryCommented:
Well,

Try what the LearnedOneSuggested. It seems more reasonable to me. I too didn't see the SET message that he mentioned in the code...I can't explain why it works for me...

Here is an article that you can see that in action:
http://vbnet.mvps.org/index.html?code/comctl/lvsubitemimages.htm

Now here is someone (bottom of article) claiming to have a trick that works:
http://www.vbforums.com/showthread.php?t=551887
0
 
SStoryCommented:
Basically I'd imagine it is still the same underlying control that MS supplies with Windows, but...the DOTNET version is a wrapper to that control and they only implemented what they wanted to. To get more functionality you have to send messages/subclass.
0
 
jr_barros_jrAuthor Commented:
SStory,

My windows is XP SP3.
0
 
SStoryCommented:
Here is an article that claims to do that and more:
http://www.codeproject.com/KB/list/extendedlistviews.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 10
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now