views:

796

answers:

1

(Using WinForms and C#. -> .Net 2.0)

I am adding nodes to a TreeView based on data in a table. As well as the caption to appear on the node, that data also contains Bitmaps.

I would like to use the Bitmap from the table as the icon on the TreeViewNode, not one from a pre-existing ImageList. (Normally you designate a Key or an Index of an image in an image list to set the node's image.)

Is this possible or do I need to add the Bitmap from my data to the ImageList (at runtime) then use that ImageList to populate the image on the node.

+4  A: 

I think you have two options. You can populate an ImageList from your data like you're suggesting, or you can draw the image onto the control yourself (with the Paint event).

lc
+1 for dynamically creating ImageList from data
routeNpingme
Yeh - that's what I've done. Seems a little overkill but works fine.
Stuart Helwig