避免在 TreeNode.ExpandAll 上扩展某些 TreeNode 节点?
以前没有人问过这个问题:
当用户执行“全部展开”操作时,避免展开 WinForms TreeView
中某些 TreeNode
类后代的有效方法是什么,但仍然如此让他通过单击 + 符号来展开这些节点?
当然,我可以处理 BeforeExpand
,但仅当它是 ExpandAll
时,我很难将 e.Cancel
设置为 true
代码>操作。我想知道如何确定这一点?我可以继承 TreeView
并覆盖 ExpandAll
——但是那个不能被覆盖......
Nobody asked that before:
What is an efficient way to avoid the expansion of certain TreeNode
class descendants in a WinForms TreeView
when the user does the "Expand all" thing, but still let him expand such nodes by clicking on the + symbol?
Sure I can handle BeforeExpand
, but I have a hard time setting e.Cancel
to true
only if it is an ExpandAll
operation. I wonder how I can determine this? I could subclass TreeView
and override ExpandAll
-- but that one cannot be overriden...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎标准 .NET 树视图没有除您描述之外的其他方式:在 ExpandAll 之前触发标志,处理 BeforeExpand 并在启用标志时为适当的节点启用 e.Cancel。
由于 ExpandAll 方法不是虚拟的,因此您可以遵循以下方法:
Seems like standard .NET treeview doesn`t have the way other than you described: trigger flag before ExpandAll, handle BeforeExpand and enable e.Cancel for appropriate nodes when flag is enabled.
As the ExpandAll method isn`t virtual you have these ways to follow:
这100%有效。我认为。叹。
This works 100%. I think. Sigh.