关于web下树的结点展开问题,以及传递状态。 我在web下建了一棵树,有好几个根结点,我想在打开一个根结点的时候,其它打开的根结点多收起来,应该怎么做呢?还有,我把树做成了用户控件,想把一棵树的状态传到另一个页面,比方说一个根结点是打开的,我想在跳转到另一个页面时也是打开的,又应该怎么做呢,请各位朋友帮忙,谢谢了,很急! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Drawing;using Microsoft.Web.UI.WebControls;namespace RunTimeWebControls{ /// <summary> /// Summary description for WebTreeView. /// </summary> [ToolboxBitmap(typeof(System.Windows.Forms.TreeView))] public class WebTreeView:TreeView { public WebTreeView() { this.SystemImagesPath = "/webctrl_client/1_0/treeimages/"; this.AutoPostBack = true; this.AutoSelect = true; this.ShowLines=true; this.ShowPlus = true; this.BorderWidth=2; this.BorderStyle = System.Web.UI.WebControls.BorderStyle.Inset; } public void ExpandAll() { foreach (TreeNode loNode in this.Nodes) { ExpandChild(loNode); } } public TreeNode GetSelectedNode() { return this.GetNodeFromIndex(this.SelectedNodeIndex); } public static void ExpandChild(TreeNode poNode) { if (poNode!=null&&poNode.Nodes.Count>0) { poNode.Expanded = true; foreach (TreeNode loNode in poNode.Nodes) ExpandChild(loNode); } } }}这个是我用的时候简单封装了一下,也许你有点启示。 loNode.GetNodeIndex(); 可以得到当前这个TreeNode对象的位置,你可以遍历,把所有展开的TreeNode的位置Index传到另外一个页面去,在把这些Node打开来。 C# 创建word文档(DOCX) 并在word文档中添加“内容控件” UserControl与Form之间怎么交互? tabcontrol 标签显示 关于DataGrid绑定及设删除功能的问题 如何收取outlook的回执信息 高分求net中如何进行调用远程Com组件 將記錄集導出到Excel問題 一个很怪的问题?(高手帮我) 请问有关于html语言解析的c#代码吗,或者给点思路,谢谢 有关数据库连接的问题? 初手问题,高手进来抠分! 如何把这一段代码改成c#的?
using System.Drawing;
using Microsoft.Web.UI.WebControls;namespace RunTimeWebControls
{
/// <summary>
/// Summary description for WebTreeView.
/// </summary>
[ToolboxBitmap(typeof(System.Windows.Forms.TreeView))]
public class WebTreeView:TreeView
{
public WebTreeView()
{
this.SystemImagesPath = "/webctrl_client/1_0/treeimages/";
this.AutoPostBack = true;
this.AutoSelect = true;
this.ShowLines=true;
this.ShowPlus = true;
this.BorderWidth=2;
this.BorderStyle = System.Web.UI.WebControls.BorderStyle.Inset;
}
public void ExpandAll()
{
foreach (TreeNode loNode in this.Nodes)
{
ExpandChild(loNode);
}
} public TreeNode GetSelectedNode()
{
return this.GetNodeFromIndex(this.SelectedNodeIndex);
} public static void ExpandChild(TreeNode poNode)
{
if (poNode!=null&&poNode.Nodes.Count>0)
{
poNode.Expanded = true;
foreach (TreeNode loNode in poNode.Nodes)
ExpandChild(loNode);
}
}
}
}这个是我用的时候简单封装了一下,也许你有点启示。