/// <summary>
/// 选中父节点
/// </summary>
/// <param name="e"></param>
public void CheckAllParentNodes(TreeViewEventArgs e) {
bool bol = true;
if (e.Node.Parent != null)
{
for (int i = 0; i < e.Node.Parent.Nodes.Count; i++)
{
if (!e.Node.Parent.Nodes[i].Checked)
bol = false;
}
e.Node.Parent.Checked = bol;
}
}
/// <summary>
/// 选中子节点
/// </summary>
/// <param name="treeNode"></param>
/// <param name="nodeChecked"></param>
public void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
{
foreach (TreeNode node in treeNode.Nodes)
{
node.Checked = nodeChecked;
if (node.Nodes.Count > 0)
{
this.CheckAllChildNodes(node, nodeChecked);
}
}
}