/// <summary> /// 绑定树节点 /// </summary> /// <param name="pid"></param> /// <param name="treeNode"></param> public void Band_TreeView(int pid,TreeNode treeNode) { string json = tree_helper.Get("Get?pid="+pid); List<TreeViewModel> list = JsonConvert.DeserializeObject<List<TreeViewModel>>(json); foreach (TreeViewModel item in list) { //实例化一个新的treenode TreeNode tn = new TreeNode(); tn.Text = item.Tname; tn.Tag = item.Id; //控件的额外属性 //向总节点添加此节点 treeNode.Nodes.Add(tn); //递归调用自身继续绑定 Band_TreeView(item.Id,tn); } }