本文共 545 字,大约阅读时间需要 1 分钟。
/// <summary> /// 树单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { treeView1.SelectedNode = e.Node; // SetTreeNodeChecked(treeView1.SelectedNode); } /// <summary> /// 节点全选/取消 /// </summary> /// <param name="tn"></param> private void SetTreeNodeChecked(TreeNode tn) { if (tn == null) return; // 若为空,则返回 if (tn.Nodes.Count > 0) { foreach (TreeNode item in tn.Nodes) { item.Checked = tn.Checked; SetTreeNodeChecked(item); } } }转载地址:http://etzmi.baihongyu.com/