Hi,
I'm experimenting with a treeview in a little C#/Winforms application. I have programatically assigned an ImageList to the treeview, and all nodes show their icons just fine, but when I click a node, its icon changes (to the very first image in the ImageList). How can I get the icon to remain unchanged?
BTW: The "SelectedImageIndex" is set to "(none)", since I don't really know what to set it to, since the image-index is different for the nodes (i guess?).
UPDATE: Here is the code of the application (I'm using Visual Studio Express 2008):
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
treeView1.BeginUpdate();
treeView1.Nodes.Clear();
treeView1.Nodes.Add("root","Project", 0);
treeView1.Nodes[0].Nodes.Add("Foo", "Foo", 2);
treeView1.Nodes[0].Nodes[0].Nodes.Add("Fizz", "Fizz", 3);
treeView1.Nodes[0].Nodes[0].Nodes.Add("Buzz", "Buzz", 3);
treeView1.Nodes[0].Nodes.Add("Bar", "Bar", 1);
treeView1.Nodes[0].Nodes[1].Nodes.Add("Fizz", "Fizz", 2);
treeView1.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("Buzz", "Buzz", 3);
treeView1.EndUpdate();
treeView1.ImageList = imageList1;
}
}
}