public void EachTreeA(TreeView tree, string str)//函数作用是采用递归显示符合条件的页面被选中
{
foreach (TreeNode tn in tree.Nodes)
{
if (tn.ChildNodes != null)
{
if (tn.Value == str)
{
tn.Checked = true;
}
EachTreeNodeA(tn, str);
}
}
}
public void EachTreeNodeA(TreeNode tn, string str)//函数作用是采用递归显示符合条件的页面被选中
{
foreach (TreeNode tnc in tn.ChildNodes)
{
if (tnc.ChildNodes != null)
{
if (tnc.Value== str)
{
tnc.Checked = true;
}
EachTreeNodeA(tnc, str);
}
}
}
{
foreach (TreeNode tn in tree.Nodes)
{
if (tn.ChildNodes != null)
{
if (tn.Value == str)
{
tn.Checked = true;
}
EachTreeNodeA(tn, str);
}
}
}
public void EachTreeNodeA(TreeNode tn, string str)//函数作用是采用递归显示符合条件的页面被选中
{
foreach (TreeNode tnc in tn.ChildNodes)
{
if (tnc.ChildNodes != null)
{
if (tnc.Value== str)
{
tnc.Checked = true;
}
EachTreeNodeA(tnc, str);
}
}
}
解决方案 »
- c# 下载文件怎么暂停 开始 和删除
- 打算用C#+SqlLite做个 诗词复习小工具,大家都来提供一下原材料
- 白菜问题
- 为控件设置输入焦点有什么用?
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~算法,欢迎思归等高手来看看~~~~~~~~~~~~~~~~~~~~~~~~~~~~~```
- 急啊,aql与xml的问题
- C#的if条件
- How to enumerate all drives of the computer?
- 关于c#异常的效率问题
- MySql中查询出一组数据后如何再插入另一个表中
- 怎样让数据库中的两个字段值自动相乘,然后赋值给同一张表中的另外一个字段?
- 彩笔求助!C#编程大量数据存在哪里?100分,管用全给 哥们毕业就靠这个了!!!
{
foreach (TreeNode node in treeNode.Nodes)
{
if(node.Text == str)
{
treeView1.SelectedNode = node;
}
if (node.Nodes.Count > 0)
{
this.CheckAllChildNodes(node, str);
}
}
} private void button1_Click(object sender, EventArgs e)
{
TreeNode node = treeView1.TopNode;//得到TreeView的根结点,注意根结点只有一个
//每次搜寻到根结点
while (node.PrevNode != null)
node = node.PrevNode;
//TraversNodes(node, "节点1");//遍历根结点
CheckAllChildNodes(node, "节点21"); }
while (node.PrevNode != null) 这个语句有时候提示未将对象引用设置为对象实例,什么原因?
node已经是根节点了,你还去获取node.PrevNode
{
CheckAllChildNodes(node, "节点21");
}
{ if (node.Text == str)
treeView1.SelectedNode = node;
foreach (TreeNode chileNode in node.Nodes)
{
this.CheckAllChildNodes(treeView1, chileNode, str);
}
}