- Add the image(s) you want to use to the ImageList.
- Assign the ImageList to the ImageList property of the TreeView.
- If your tree nodes are static (set at design time), you can set the ImageIndex and SelectedImageIndex properties of the node in the designer.
- If your tree nodes are dynamic (built at run time), you set those same properties in your code.
- If you only want an image when the node is selected, don't set the ImageIndex, just the SelectedImageIndex.
-Dell
A computer only does what you actually told it to do - not what you thought you told it to do.
Thats great - thanks for your help.
However when looking at the MSDN help - it says that the bug has been fixed in Net 2.0 - when you images dont show on treeviews if you have called EnableVisualStyles() - well Im running version 2 and the problem is still there - anyone else find this too.
How annoying - I got the images to work in the treeview and they look cool - but when I installed my code on the test machine - the images would not show - just had blank areas on the treeview!!!
Anyone know how to get around this? I have tried the DoEvents() solution after EnableVisualStyles() call, but to no avail - should I be embedding the bmp icons or something in some special way???
I haven't had this issue. Are you doing this on the web? The places where I've used this have all been WinForms apps. Maybe you need to make sure that the .resx file gets deployed with your application?
-Dell
A computer only does what you actually told it to do - not what you thought you told it to do.
No these are WinForms apps. The bug/error appears intermittently between every rebuild/release of my code (hence the diffiuclty with nailing this!) - sometimes the icons show, sometimes not - and between release, the code to do with the treeview has not been altered.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.