一个学生管理系统,希望按照入学时间来分,怎样在添加记录的时候判断入学时间是否在已经存在的节点上,如果没有就自动添加一个节点

解决方案 »

  1.   

    TreeNode 对象...
     往接点的Nodes集合中加.
      

  2.   


     /// <summary>
            /// 自动创建树形节点
            /// </summary>
            private void CreatTree()
            {
                DataSet ds = new DataSet();
                BLL.DeviceGroup bll = new BLL.DeviceGroup(); 
                ds = bll.GetGroup();//从设备组里得到全省城市名
                int count = ds.Tables[0].Rows.Count;
                
                //根节点
                for (int i = 0; i < count; i++)
                {
                    if (ds.Tables[0].Rows[i][1].ToString() == "...")
                    {
                        TreeNode tn = new TreeNode();
                        tn.Value = "...";
                        tn.Text = "...";
                        tv.Nodes.Add(tn);                    TreeNode tn1 = new TreeNode("...");
                        tv.Nodes.Add(tn1);
                    }
                    else
                    {
                        continue;
                    }
                }
                //一级子节点
                for (int j = 0; j < count; j++)
                {
                    if (ds.Tables[0].Rows[j][0].ToString().Length == 2 && (ds.Tables[0].Rows[j][1].ToString() != "..."))
                    {
                        TreeNode tn = new TreeNode(ds.Tables[0].Rows[j][1].ToString());
                        tv.Nodes[0].ChildNodes.Add(tn);
                    }
                }