TreeView with more than one icon
I would like to put more than one icon in a TreeView ( Winforms, .Net 3.5 ). I've took a look at this codeproject project ( http://www.codeproject.com/KB/tree/treeviewadv.aspx ) but it doesn't work for me.
If it's possible I don't want to change our current TreeView, i.e. 开发者_JS百科I don't want to use a commercial tool.
It's possible to do this by my own?
Thank you very much.
Regards,
Vicenç
If you set the DrawMode property on your current TreeView to OwnerDrawAll, it's easy to draw as many icons as you want. You become responsible for drawing all of the elements of the rectangular area that makes up each node manually, including the icons, checkboxes, plus and minus signs, and connecting lines, which means you can customize its appearance almost endlessly.
When a TreeView is set to owner draw, the DrawNode event is fired for each node that needs to be painted. MSDN gives a sample of how you might implement this: http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.drawnode.aspx.
For drawing the actual icons, you'll want to look into the Graphics.DrawIcon method.
You can use the StateImageList as a 'secondary' image source.
Note that this does have some bugs, notably only having 4 bit color support.
精彩评论