示例#1
0
		// Collapse the children recursively but don't redraw.
		private void CollapseInternal()
		{
			bool selected = false;
			// Recursively collapse, if a child was selected, mark to select the parent.
			if (childCount > 0)
			{
				for (int i = 0; i < childCount; i++)
				{
					if (treeView.SelectedNode == children[i])
						selected = true;
					children[i].CollapseInternal();
				}
			}
			// Do the events.
			TreeViewExCancelEventArgs eventArgs = new TreeViewExCancelEventArgs(this, false, TreeViewExAction.Collapse);
			treeView.OnBeforeCollapse(eventArgs);
			if (!eventArgs.Cancel)
			{
				treeView.OnAfterCollapse(new TreeViewExEventArgs(this));
				// The node is now collapsed.
				expanded = false;
			}
			if (selected)
			{
				treeView.SelectedNode = this;
			}
		}