日期:2014-05-18 浏览次数:20971 次
private void loadtree() { TreeView1.Nodes.Clear(); TreeView1.Nodes.Add(new TreeNode("系统说明", "About", "")); TreeView1.Nodes.Add(new TreeNode("--------","xian")); TreeNode tn = new TreeNode("aaa", "yuyue"); tn.ChildNodes.Add(new TreeNode("bbb", "Registered", "", "~/A_Registered.aspx", "")); tn.ChildNodes.Add(new TreeNode("ccc", "RegistSelect", "", "~/S_RegistSelect.aspx", "")); //tn.ImageUrl = "~/images/menu_bt.jpg"; TreeView1.Nodes.Add(tn);
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { int a=this.TreeView1.CheckedNodes.Count; int b = this.TreeView1.Nodes.Count; int c = this.TreeView1.SelectedNode.ChildNodes.Count; //int d = this.TreeView1.SelectedNode.Parent.ChildNodes.Count; for (int i = 0; i < this.TreeView1.Nodes.Count; i++) { if (this.TreeView1.SelectedValue == this.TreeView1.Nodes[i].Value) { this.TreeView1.SelectedNode.Expanded = true; } else { for (int j = 0; j < this.TreeView1.SelectedNode.ChildNodes.Count; j++) { this.TreeView1.SelectedNode.ChildNodes[j].CollapseAll(); } //this.TreeView1.SelectedNode.Parent.Expanded = true; this.TreeView1.SelectedNode.Expanded = true; } }