cviewtree获得节点是展开还是收缩
展开全部
aspx中有:
<asp:TreeView ID="TreeView1" runat="server" ShowLines="True" ExpandDepth="0"
OnTreeNodeExpanded="TreeView1_OnTreeNodeExpanded" Target="RightFrame">
<Nodes>
。。。此处省略。重点是下面添加事件:
protected void TreeView1_OnTreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
//同级只展开一个使用下列程序
/*TreeNodeCollection ts = null;
if (e.Node.Parent == null)
{
ts = ((TreeView)sender).Nodes;
}
else
ts = e.Node.Parent.ChildNodes;
foreach (TreeNode node in ts)
{
if (node != e.Node)
{
node.Collapse();
}
} */
//只展开一个第一级使用下列程序
TreeNodeCollection ts = null;
if (e.Node.Parent == null)
{
ts = ((TreeView)sender).Nodes;
foreach (TreeNode node in ts)
{
if (node != e.Node)
{
node.Collapse();
}
}
}
}//TreeView1_OnTreeNodeExpanded
<asp:TreeView ID="TreeView1" runat="server" ShowLines="True" ExpandDepth="0"
OnTreeNodeExpanded="TreeView1_OnTreeNodeExpanded" Target="RightFrame">
<Nodes>
。。。此处省略。重点是下面添加事件:
protected void TreeView1_OnTreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
//同级只展开一个使用下列程序
/*TreeNodeCollection ts = null;
if (e.Node.Parent == null)
{
ts = ((TreeView)sender).Nodes;
}
else
ts = e.Node.Parent.ChildNodes;
foreach (TreeNode node in ts)
{
if (node != e.Node)
{
node.Collapse();
}
} */
//只展开一个第一级使用下列程序
TreeNodeCollection ts = null;
if (e.Node.Parent == null)
{
ts = ((TreeView)sender).Nodes;
foreach (TreeNode node in ts)
{
if (node != e.Node)
{
node.Collapse();
}
}
}
}//TreeView1_OnTreeNodeExpanded
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询