Пример #1
0
        internal static void AddFolder(TreeView tvWebResources, Control mainControl)
        {
            var selectedNode = tvWebResources.SelectedNode;
            var nfd = new NewFolderDialog { StartPosition = FormStartPosition.CenterParent };

            if (nfd.ShowDialog(mainControl) == DialogResult.OK)
            {
                var parts = nfd.FolderName.Split('/');
                var currentNode = selectedNode;

                foreach (var part in parts.Where(x => x.Length > 0))
                {
                    var node = new TreeNode(part.Trim()) { ImageIndex = 1, SelectedImageIndex = 1 };

                    currentNode.Nodes.Add(node);
                    tvWebResources.SelectedNode = node;
                    currentNode = node;
                }
            }

            tvWebResources.TreeViewNodeSorter = new NodeSorter();
            tvWebResources.Sort();
        }
Пример #2
0
        /// <summary>
        /// Create a new folder in the treeview
        /// </summary>
        public void CreateFolder()
        {
            var selectedNode = tv.SelectedNode;
            var nfd = new NewFolderDialog { StartPosition = FormStartPosition.CenterParent };

            if (nfd.ShowDialog(ParentForm) == DialogResult.OK)
            {
                var parts = nfd.FolderName.Split('/');
                var currentNode = selectedNode;

                foreach (var part in parts.Where(x => x.Length > 0))
                {
                    var node = new TreeNode(part.Trim()) { ImageIndex = 1, SelectedImageIndex = 1 };

                    currentNode.Nodes.Add(node);
                    tv.SelectedNode = node;
                    currentNode = node;
                }
            }

            tv.TreeViewNodeSorter = new NodeSorter();
            tv.Sort();
        }