【发布时间】:2013-08-25 05:38:50
【问题描述】:
我在 VS 2012 中使用 .net c# 并尝试编写一个函数来自动检查已检查父树视图节点的所有子节点。我是 c# 编程新手,所以我找到了以下代码,但它有两个问题:
- if (HasChildNodes(node)) Visual Studio 报告 HasChildNodes 的行未知。
- 我想从单击检查的选定节点开始,我认为代码遍历整个树?
感谢您的帮助。
treeView.BeginUpdate();
//Loop through all the nodes of tree
foreach (TreeNode node in treeView.Nodes)
{
//If node has child nodes
if (HasChildNodes(node))
{
if (node.Checked == true)
{
//Check all the child nodes.
foreach (TreeNode childNode in node.Nodes)
{
childNode.Checked = true;
}
}
}
}
treeView.EndUpdate();
【问题讨论】:
标签: c# .net visual-studio-2012