void MyTreeToolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Name) { case "ChildNodes": { break; } case "ShowAll": { ToolStripMenuItem tsm = ((ToolStripMenuItem)e.ClickedItem); if (tsm.CheckState == CheckState.Checked) { tsm.CheckState = CheckState.Unchecked; _myTree.ShowAllFiles = false; UnShowAllFile(); } else if (tsm.CheckState == CheckState.Unchecked) { tsm.CheckState = CheckState.Checked; _myTree.ShowAllFiles = true; ShowAllFile(); } break; } case "Refresh": { string[] openItem = _myTree.OpenItems; _myTree.BeginUpdate(); _myTree.UnloadTreeData(); _myTree.LoadTreeData(); _myTree.OpenItems = openItem; _myTree.EndUpdate(); break; } case "CollapseAll": { _myTree.CollapseAll(); break; } case "ExpandAll": { TreeNode nextVisibleNode = _myTree.Nodes[0]; while (nextVisibleNode != null) { TreeNode tempNode = nextVisibleNode; nextVisibleNode = nextVisibleNode.NextVisibleNode; tempNode.Expand(); } break; } } }
public void UnloadTreeData() { _myTree.UnloadTreeData(); _toolStrip.SetVisualForDisposeTree(); }