Solved

Add image to subitem in listview

Posted on 2009-05-03
20
2,492 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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

739 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