I have a TreeView where every node has a folder icon and I want that when those are expanded/collapsed that the folder icon changes. I don't want the icon to change when the node is only selected. So I have these event handlers for that
private void Tree_AfterExpand(object sender, TreeViewEventArgs e)
{
e.Node.ImageIndex = 3;
}
private void Tree_AfterCollapse(object sender, TreeViewEventArgs e)
{
e.Node.ImageIndex = 2;
}
// and this
TreeNode node = new TreeNode("My Node", 2, 2);
The problem is that when I select the item, since the default SelectedImageIndex in 0, it changed the folder icon to something else.
I have also tried just not setting a SelectedImageIndex but that defaults to 0 when the node is clicked. Is there any way to completely prevent all icon changes when selecting a node? Or what is the solution to this problem?