简体   繁体   English

c#WinForms检测TreeView的真实可见性

[英]c# WinForms Detect real visibility of TreeView

I have a WinForms TreeView and a tree, built from custom node objects which inherits TreeNode the problem is that these nodes can be displayed in only one tree at the time. 我有一个WinForms TreeView和一棵树,该树是从继承TreeNode的自定义节点对象构建的,问题是这些节点当时只能显示在一棵树中。 Now I have multiple controls with a TreeView that should display these nodes. 现在,我有多个带有TreeView的控件,这些控件应显示这些节点。 How can I indicate that the treeView is displayed? 如何指示显示了treeView? I can catch the VisibleChanged event but I don't know how to detect if the TreeView is really visible (The visible property does not change!). 我可以捕获VisibleChanged事件,但是我不知道如何检测TreeView是否真正可见(visible属性不会改变!)。

I know that one solution can be to wrap my data in TreeNode objects and not using inheritance from TreeNode. 我知道一种解决方案可以是将我的数据包装在TreeNode对象中,而不要使用TreeNode的继承。 But I hope there is a faster solution. 但我希望有一个更快的解决方案。

How do you decide which treeview gets to display the items? 你如何决定哪个树形视图得到显示的项目?

Generally, I don't think that's a good design at all. 通常,我认为这根本不是一个好的设计。 Better use an FeedTreeNode(MyObject o) and a suitable updater. 最好使用FeedTreeNode(MyObject o)和合适的更新程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM