PDA

View Full Version : Adding image to listView's subItems


labbejason
11-04-2009, 07:05 PM
Is there a way to add images in a listView's subItems? I can only add an image in the 1st row right now.

(
rollout dialog_lvTest "LV test"
(
local imageFile = "C:\\Documents and Settings\\jlabbe\\Desktop\\testIcon.jpg"

dotNetControl lv "System.Windows.Forms.ListView" width:480 height:480 align:#center

on dialog_lvTest open do
(
-- Setup lv's properties
lv.View = (dotNetClass "System.Windows.Forms.View").details
lv.gridLines = true

-- Add columns
columns = #("Object", "wireColor")
lv.columns.add columns[1] 230
lv.columns.add columns[2] 230

-- Create image object
imageList = dotNetObject "System.Windows.Forms.ImageList"
imageClass = dotNetClass "System.Drawing.Image"
imageList.images.add (imageClass.Fromfile imageFile)

-- Add rows
rows = #()
for obj in objects do
(
item = dotNetObject "System.Windows.Forms.ListViewItem" obj.name
item.subitems.add (obj.wireColor as string)
item.ImageIndex = 0
append rows item
)
lv.items.addRange rows
lv.SmallImageList = imageList
)
)
createDialog dialog_lvTest 500 500
)

MarcoBrunetta
11-04-2009, 07:53 PM
AFAIK, with the standard listview, you can't add images to the subitems, just one per row.

labbejason
11-04-2009, 07:57 PM
... nooooo!

I guess the only decent solution would be to have 2 listViews?

Edit: This was my reaction when I read your response:
http://www.youtube.com/watch?v=phGzXh3z55c

MarcoBrunetta
11-04-2009, 08:00 PM
:D

Well, that's one option, but it depends on what you are trying to do. Maybe doing something like using a flowlayoutpanel that you can fill with your own controls is an option? Or you could play around with the XtraTreeList thingy everyone's been raving about, I'm pretty sure that can generate a listView with several images per row.

denisT
11-04-2009, 08:08 PM
AFAIK, with the standard listview, you can't add images to the subitems, just one per row.

it's kinda true. by default only main item has an image. but there are couple ways how to add images to sub items. the most popular is to overwrite sub item drawing - add your own code to listView drawSubItem event...

labbejason
11-04-2009, 08:09 PM
I was just going to have icons to use them as an item's checked state. I'm aware you can actually replace the actual checkbox with an image, but listView doesn't allow any checkboxes in its subItems.

it's kinda true. by default only main item has an image. but there are couple ways how to add images to sub items. the most popular is to overwrite sub item drawing - add your own code to listView drawSubItem event...

Thanks, I'll check that out.

denisT
11-04-2009, 08:17 PM
I was just going to have icons to use them as an item's checked state. I'm aware you can actually replace the actual checkbox with an image, but listView doesn't allow any checkboxes in its subItems.



Thanks, I'll check that out.

use "DevExpress.XtraTreeList.TreeList" control... it's free for all max users.

CGTalk Moderation
11-04-2009, 08:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.