private void tvClass_AfterCheck(object sender, TreeViewEventArgs e)
{
SelectAllOrInverse(e.Node.Nodes, e.Node.Checked);
}
//全选或反选
protected void SelectAllOrInverse(TreeNodeCollection tnc, bool b)
{
foreach (TreeNode node in tnc)
{
node.Checked = b;
SelectAllOrInverse(node.Nodes, b);
}
}
此方法比较通用,在获取勾选项的时候略加修改也可以使用