I've filled out an imagelist for my treeview with 5 ico files. For some reason, I can only use 2 of those images, index 0,1, after those images I get an index out of range error. I set the treeview.imagelist = to my created imagelist as follows:
Dim imglst As New ImageList()
imglst.Images.Add(Image.FromFile("C:\Projects\File_Rename\computer.ico"))
imglst.Images.Add(Image.FromFile("C:\Projects\File_Rename\drive.ico"))
imglst.Images.Add(Image.FromFile("C:\Projects\File_Rename\folder1.ico"))
imglst.Images.Add(Image.FromFile("C:\Projects\File_Rename\folder2.ico"))
imglst.Images.Add(Image.FromFile("C:\Projects\File_Rename\file1.ico"))
tvwDir.ImageList = imglst
tvwDir.Nodes.Add("root", "My Computer")
tvwDir.Nodes.Item(0).ImageIndex = 0
tvwDir.Nodes(0).Nodes.Add(drv.ToString)
tvwDir.Nodes(0).Nodes.Item(drvindex).ImageIndex = 1
node.Nodes.Add(dir.ToString.Substring(3, dir.ToString.Length - 3))
node.Nodes.Item(dirindex).ImageIndex = 2
The red part is where I'm getting the outside of index error. Is this because my files are not readable, or is it because there is a 2 index limit to an imagelist? The examples I've seen have many images in an imagelist. When I do just the first 2 indexes, it sets my root as the computer.ico, then the 2nd level nodes are set to drive.ico. All subsequent nodes are set to computer.ico.
Don't worry about the semantics of my code, it's snippets relevant to the question extracted from the whole.