TreeNode in TreeView: How to deselct TreeNode RRS feed

  • Question

  • Hi,

    Is it possible to make a treeview work so that, if I click an already selected TreeNode, it is deselected? I cannot get it to work the way I want to!

    I've tried several things that all looks something like this:

            private void treeview1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
                selectedNode = e.Node.Tag.ToString();
                if (selectedNode == selectedNodePrevious)
                    treeview1.SelectedNode = null;
                    selectedNodePrevious = "";
                    selectedNodePrevious = selectedNode;

    Any help would be appreciated!


    Friday, November 16, 2012 6:56 PM