Treeview and Imagelist Problem - Please Help

Joined
Jun 18, 2006
Messages
23
Programming Experience
3-5
I am trying to use a treeview and imagelist.

I added 3 images to the imagelist.

I have set the treeview's imagelist property to the imagelist I added to the form.

Here is some sample code for when I programmatically add nodes to the treeview.

nd = TreeView1.TopNode.Nodes.Add("", reader.ReadString, 0)

Then I tried:

nd.SelectedImageIndex = 0


I keep getting the following error, and it never points to the offending line of code.

"An error occurred creating the form. See Exception.InnerException for details. The error is: Index was outside the bounds of the array."
 
OK, I created a BRAND NEW project.

1) added a treeview and listview to the form

2) added an imagelist to the form

3) added one image to the imagelist

4) did not link the imagelist to a control

5) ran the application. ERROR

The same error occurs. WHY?!

Can one or more of the mods please help me?

This doesn't make any sense.
 
I have no such issue. By the way, the ImageList is not a control. It is a component.
 

Attachments

  • TreeViewImageList.JPG
    TreeViewImageList.JPG
    64.5 KB · Views: 50
Hi thanks for the reply. I hope we can get to the bottom of this and find a solution!

Here is a screen cap of the error. Again, the form is never displayed. And this only happened by adding an Imagelist component and one image.

error2vo.png
 
Sounds very strange, perhaps you should post the solution zipped (without the 'obj' and 'bin' folders), maybe one of the forums users will have a look at it and be able to help you.
 
I guess my problem has just been solved.

Apparently, one has to save the project before running it with the images in the imagelist?

Once I saved the project, which I was reluctant to do because of the crashes, it worked.
 
Back
Top