Solved

Add image to subitem in listview

Posted on 2009-05-03
20
2,515 Views
Last Modified: 2013-11-26
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
Comment
Question by:jr_barros_jr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 4
  • +1
20 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 24296848
I've never seen a listview in detail mode that had subitems with images.
Have you?
0
 
LVL 4

Expert Comment

by:Thunder724
ID: 24297288
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24297744
I could think of a way, but I am curious how easy it was in VB6 (I have been away far too long)?  
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 25

Expert Comment

by:SStory
ID: 24297905
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24297939
@SStory
That is a long list.  Which specific reference are you talking about?
0
 
LVL 25

Expert Comment

by:SStory
ID: 24299032
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
 
LVL 25

Expert Comment

by:SStory
ID: 24299050
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
 

Author Comment

by:jr_barros_jr
ID: 24299085
@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
 
LVL 25

Expert Comment

by:SStory
ID: 24299328
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24299687
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
 

Author Comment

by:jr_barros_jr
ID: 24300830
@TheLearnedOne:

What is your code? Is a solution?
0
 

Author Comment

by:jr_barros_jr
ID: 24300835
@SStory:

Your are correct. My mistake. I meant Outlook e-mails. You can have Flag, Unread/read icon message etc.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24301251
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
 
LVL 25

Expert Comment

by:SStory
ID: 24304275
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
 

Author Comment

by:jr_barros_jr
ID: 24310271
@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
 
LVL 25

Expert Comment

by:SStory
ID: 24313985
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
 
LVL 25

Expert Comment

by:SStory
ID: 24314032
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
 
LVL 25

Expert Comment

by:SStory
ID: 24314088
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
 

Author Comment

by:jr_barros_jr
ID: 24316403
SStory,

My windows is XP SP3.
0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 24317324
Here is an article that claims to do that and more:
http://www.codeproject.com/KB/list/extendedlistviews.aspx
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question