【发布时间】:2016-08-23 13:14:47
【问题描述】:
我正在使用 Telerik OrgChart 控件。我基本上在努力从节点中提取渲染字段。您可以将 OrgChartRenderedField 添加到每个节点;这有一个名为 Label 的属性。
每个节点的每个 OrgChartRenderedField 都包含在 OrgChartRenderedFieldCollection
中public class OrgChartRenderedFieldCollection : System.Collections.Generic.List<OrgChartRenderedField>
Member of Telerik.Web.UI
它有一个名为 find() 的方法
public T Find(System.Predicate<T> match)
Member of System.Collections.Generic.List<T>
总结: 搜索与指定谓词定义的条件匹配的元素,并返回整个 System.Collections.Generic.List 中的第一个匹配项。
参数: match:定义要搜索的元素条件的 System.Predicate 委托。
返回: 与指定谓词定义的条件匹配的第一个元素(如果找到);否则,T 类型的默认值。
例外情况: System.ArgumentNullException:匹配为空。
我遇到的主要问题是我不知道如何在集合中搜索 Label = 'Some text' 的特定 OrgChartRenderedField 对象 欣赏它是第三方插件;希望知道对象的类型有人可以给我一个建议。 谢谢。
【问题讨论】:
-
那个方法是
List<T>的一部分,应该和list.Find(o => o.Label == "Some Text")一样简单 -
请参阅this answer 了解谓词委托的说明。