I would like to thank contributors in advanced, I am rather stuck on this one:
I have created a List View called listView1 and when the program runs it displays data files (.txt, .doc etc) from a particular folder specified in a Tree View called treeView1. In these same folders next to the data files are icon files(.ico). I would like to assign a .ico to be displayed as the image for the .txt or .doc file that will be loaded into listView1. Both the data file and icon file have the same name just a different extension. Therefor I already have a way of matching the icon file to the data file. However, I cannot seem to find a way to programically assign the icon file as the image to be displayed for the data file in listView1. I cannot use a Image List because you can only assign images from a image list based on its image index not its name. All signs seem to point to creating a array but I cannot figure out how to assign an image in a array to a data file while I am adding it to listView1.
I hope that makes sense, thank you!
Once you have added your image files to an ImageList, you most certainly CAN refer to them by their name (the ImageKey property). The following code works. It is rather crude, because I have no idea how you are populating your Treeview or Listview with data. I just threw in some test data and used common means of populating Treenodes and ListViewItems.
Hope this helps. Let me know if you have questions . . .