zoukankan      html  css  js  c++  java
  • ASP.NET下的TreeView控件的使用(生成树与统计所有子节点数量)

     
    View Code
     1 //GetAllNodeText(trvPlacement.Nodes);  //统计TreeView所有子节点数量
     2 
     3     private void GetAllNodeText(TreeNodeCollection tnc)  //统计TreeView所有子节点数量
     4     {
     5         foreach (TreeNode node in tnc)
     6         {
     7             if (node.ChildNodes.Count != 0)
     8             {
     9                 GetAllNodeText(node.ChildNodes);
    10             }
    11             node.Text = node.Text + GetNodesCount(node); 
    12         }
    13     }
    14 
    15     private int GetNodesCount(TreeNode tnc)  //统计TreeView节点下所有子节点数量
    16     {
    17         int intCount = tnc.ChildNodes.Count;
    18         if (tnc.ChildNodes.Count > 0)
    19         {
    20             foreach (TreeNode node in tnc.ChildNodes)
    21             {
    22                 intCount = intCount + GetNodesCount(node);
    23             }
    24         }
    25         return intCount;
    26     }
    27 
    28     private void InitTree(TreeNode Nd, String Parent_id) //子树节点加载函数
    29     {
    30         DataRow[] rows = dtbUserAllInfo.Select("Parent=" + Parent_id);
    31         if (rows != null)
    32         {
    33             for (int i = 0; i < rows.Length; i++)
    34             {
    35                 TreeNode Tnd = new TreeNode();
    36                 DataRow dr = rows[i];
    37                 Tnd.Text = dr["Name"].ToString();
    38 
    39                 intPeopleNum += 1;
    40                 Nd.ChildNodes.Add(Tnd);
    41                 InitTree(Tnd, dr["ID"].ToString());//递归调用
    42             }
    43         }
    44     }
  • 相关阅读:
    LINUX_bash
    【c++】必须在类初始化列表中初始化的几种情况
    Hadoop 学习笔记 (八) hadoop2.2.0 测试环境部署 及两种启动方式
    hadoop各版本下载
    mapreduce (六) MapReduce实现去重 NullWritable的使用
    hadoop 生态系统版本对应问题
    mapreduce (五) MapReduce实现倒排索引 修改版 combiner是把同一个机器上的多个map的结果先聚合一次
    mapreduce (四) MapReduce实现Grep+sort
    ctr预估模型
    mapreduce (七) 几个实例
  • 原文地址:https://www.cnblogs.com/prolion/p/2514833.html
Copyright © 2011-2022 走看看