Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable SelectedImageIndex in Treeview

I'm using a treeview-control in winforms and an imagelist to display different states of the treeview-elements.

But i don't want to use the selected element to use a different image.

Is there a way to disable SelectedImageIndex in the TreeView-control?

If tried to change the selectedimageindex after every selection. Something like this:

    private void TreeView1AfterSelect(object sender, TreeViewEventArgs e)
    {
        treeView1.SelectedImageIndex = treeView1.SelectedNode.ImageIndex;
    }

But this causes a pretty ugly flickering of the control after every selection..

like image 954
Kingpin Avatar asked Dec 01 '11 15:12

Kingpin


1 Answers

When you are creating the new TreeNode, assign the same imageindex to ImageIndex and SelectedImageIndex:

...
node.SelectedImageIndex = node.ImageIndex;
...
like image 98
Daniel Peñalba Avatar answered Oct 02 '22 21:10

Daniel Peñalba