Reputation: 1119
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..
Upvotes: 14
Views: 8085
Reputation: 21
When creating the node
Dim nd As New TreeNode("NodeKey", "NodeText", 1, 1)
The two indices are for ImageIndex and SelectedImageIndex.
Upvotes: 2
Reputation: 31887
When you are creating the new TreeNode
, assign the same imageindex to ImageIndex
and SelectedImageIndex
:
...
node.SelectedImageIndex = node.ImageIndex;
...
Upvotes: 29