private void InitializeTreeview()
        {
            if (Vault != null)
            {
                FolderCollection folderCollection = Vault.DefaultStore.Library.GetTopLevelFolders();
                VvTreeNode       node;
                foreach (Folder folder in folderCollection)
                {
                    node = new VvTreeNode(folder.FolderID, folder.Name);
                    node.Nodes.Add(new VvTreeNode(Guid.Empty, ""));
                    TreeView1.Nodes.Add(node);
                }

                if (TreeView1.GetNodeCount(false) > 0)
                {
                    //if selected folder ID was passed in then try and find that folder in the tree
                    //and selected it

                    if (_selectedFolderId.Equals(Guid.Empty))
                    {
                        node = (VvTreeNode)TreeView1.Nodes[0];
                        if (node != null)
                        {
                            TreeView1.SelectedNode = node;
                            LoadChildTreeNodes(node);
                            _selectedFolder = Vault.DefaultStore.Library.GetFolder(node.NodeID);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("You are not logged in to the Target VisualVault Server", "Error", MessageBoxButtons.OK);
            }
        }
        private void TreeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            var node = (VvTreeNode)e.Node;

            if (node.GetNodeCount(true) == 1)
            {
                var childnode = (VvTreeNode)node.Nodes[0];
                if (Guid.Empty.Equals(childnode.NodeID))
                {
                    node.Nodes.Remove(childnode);
                    Guid             folderId1        = node.NodeID;
                    FolderCollection folderCollection = Vault.DefaultStore.Library.GetChildFolders(folderId1);
                    foreach (Folder folder in folderCollection)
                    {
                        var newnode = new VvTreeNode(folder.FolderID, folder.Name);
                        newnode.Nodes.Add(new VvTreeNode(Guid.Empty, ""));
                        node.Nodes.Add(newnode);
                    }
                }
            }
        }
        private void LoadChildTreeNodes(VvTreeNode node)
        {
            VvTreeNode childnode;

            if (node.GetNodeCount(true) == 1)
            {
                childnode = (VvTreeNode)node.Nodes[0];
                if (Guid.Empty.Equals(childnode.NodeID))
                {
                    node.Nodes.Remove(childnode);
                }
            }
            FolderCollection fldrColl = Vault.DefaultStore.Library.GetChildFolders(node.NodeID);

            foreach (Folder folder in fldrColl)
            {
                childnode = new VvTreeNode(folder.FolderID, folder.Name);
                childnode.Nodes.Add(new VvTreeNode(Guid.Empty, ""));
                node.Nodes.Add(childnode);
            }
            node.Expand();
        }