private void PopulateTree() { VirtualTreeNode selectedNode = treeView.SelectedNode; Folder selectedFolder = selectedNode == null?null: selectedNode.Tag as Folder; EmptyTree(); TreeNodeGroupAcceptor tnga = new TreeNodeGroupAcceptor(treeView, true); Search.SearchForAllFolders().PopulateAdapters(tnga); if (selectedFolder != null) { // try the one we were on: if that's no longer present, back off to the one we started with if (!SelectNode(selectedFolder.opaque_ref)) { string folder = orig_folder; SelectNode(folder); } } else { SelectNode(null); } }
private void PopulateTree() { try { treeView.BeginUpdate(); //repopulate the tree treeView.Nodes.Clear(); var tnga = new TreeNodeGroupAcceptor(treeView, true); Search.SearchForAllFolders().PopulateAdapters(tnga); //restore selection SelectNodeByRef(selectedFolderRef); } finally { treeView.EndUpdate(); } }