ASP.NET:如何创建一个可扩展的空树节点 [英] ASP.NET: How to Create an Expandable Empty TreeNode

查看:152
本文介绍了ASP.NET:如何创建一个可扩展的空树节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要填充 TreeNode.ChildNodes TreeView.TreeNodeExpanded 的事件。问题是之前会触发该事件节点是空的,这是不是在这种情况下,扩展并没有展开图标 [+] 显示在它旁边。

I need to populate the TreeNode.ChildNodes on the event of TreeView.TreeNodeExpanded. The problem is the node is empty before the event gets fired and it is not expandable in this case and there is no expand icon [+] showed next to it.

我想在的情况下扩展节点及其关联对象有一些孩子不添加这些孩子的节点。

I want to make the node expandable in case its related object has some children without adding those children to the node.

我想过添加虚拟孩子节点,并删除它,当它展开。是否有更好的选择?

I thought about adding a virtual child to the node and delete it when it is expanded. Are there any better options ??

感谢您。

推荐答案

三个步骤做的伎俩:

1 - 设置 TreeView控件。 ExpandDepth 来的 0 的。这消除了加入树节点对象在 TreeView控件的扩展和显示扩展符号的 [+] 相邻树节点具有 TreeNode.PopulateOnDemand 属性设置为的真正

1 - Set the TreeView.ExpandDepth to 0. This eliminates the expansion of the added TreeNode objects in the TreeView and shows the expansion symbol [+] next to each TreeNode that has the TreeNode.PopulateOnDemand property set to true.

2 - 将<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treenode.populateondemand.aspx\"相对=nofollow> TreeNode.PopulateOnDemand 来的真正的每个分支树节点。当 TreeNode.ChildNodes 收集的的,扩展符号的 [+] 将仅次于拿给树节点 TreeNode.PopulateOnDemand 属性设置为对象的真正

2- Set the TreeNode.PopulateOnDemand to True for each branch TreeNode. When the TreeNode.ChildNodes collection is empty, the expansion symbol [+] will be showed only next to TreeNode objects that has TreeNode.PopulateOnDemand property set to true.

3握住<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.treenodepopulate.aspx\"相对=nofollow> TreeView.TreeNodePopulate 事件poulate扩张分支节点。此事件将被解雇时,树节点 - 以 TreeNode.PopulateOnDemand 设置的真正的 - 已在 TreeView.TreeNodeExpanded 事件被炒鱿鱼前右扩展

3- Handle the TreeView.TreeNodePopulate event to poulate branch nodes on expansion. This event will be fired when a TreeNode - with the TreeNode.PopulateOnDemand set to true - has been expanded right before the TreeView.TreeNodeExpanded event gets fired.

这篇关于ASP.NET:如何创建一个可扩展的空树节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆