I am trying to setup a treeview control to display all drives and folders on the PC. So far I can display all drives and folders but the images will not show except rarely. I am using an imagelist with 4 images (index 0-3). The code below is used to load the drives in the treeview control. I have tried using every type of image possible from bmp to png and nothing. I have tried the Appllication.EnableVisualStyles() which I now know isn't needed in vs 2008. I am also having problems with a picturebox in another form that shows nothing but a shadow of the image. I suspect this may be a setting somewhere maybe in vs 2008 but am not able to find one.
Sounds peculiar. first thing I'd do though is get rid of (or at least rearrange) the try...catch block - you should only use them if there is no way of knowing whether an operation will succeed (like for example trying to access a CD drive without knowing if there is a disc in it). This certainly isn't the case for lines like oNode.ImageIndex = 3. Maybe it is when you are testing the ToString of the drive - if that is the case the try..catch should be wrapping just this one line.
Can you elaborate - when you say the images show rarely.. have you been able to identify any patrern as to in what circumstances the images do show up. As for the picturebox showing only a shadow of an image - it should really be a separate thread, but can you give us a screenshot of what it looks like and another of the actual image as it should show?
and the picturebox that I am having trouble with. The pic to the left is what it should look like. I may do a separate thread on this tho. Just thought they might be related somehow.
I have not been able to find a pattern as to when the images do show in the treeview except that it will be the first time I run the program but not every time.
I wonder if the ghost image is something to do with the colour depth of the images... try opening the image up in an image editor and reducing changing that and re-trying.
I'm guessing this ghosting problem only occurs with certain images not all images?
I was thinking the same thing and so far I have tried png,jpg,bmp, and gif without success. I haven't tried changing the color depth tho I will give that a try and see what happens. Any ideas on the images in the treeview?
Well it seems it is not the color depth in the treeview. I have tried all settings from 8 bit to 32 bit without luck. However I did notice the size of the images was 48x48 so I set the imagelist to 48x48 and it worked. After that I went into photoshop and changed the size to 16x16 and tried again. This didn't work. Again I tried the color depth without success. This has really got me baffled.