本文整理汇总了C#中TreeNode.Find方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.Find方法的具体用法?C# TreeNode.Find怎么用?C# TreeNode.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode.Find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
tree = TreeNode.Create("first").With(TreeNode.Create("second").With("third"))
.With("fourth")
.With(TreeNode.Create("fifth").With("sixth"));
//Flatten();
//FindNode();
//FindNode(node => Console.WriteLine(node.Item));
var node = tree.Find(n => n.Item.StartsWith("fo"));
Console.WriteLine(node.Item);
}
示例2: FillTree
} //Main()
public static void FillTree(TreeNode InputNode)
{
//Fill the tree with all the types in the BCL assembly in inheritence hierarchy.
Type [] types = typeof(object).Module.Assembly.GetExportedTypes();
InputNode.AddChild(new TreeNode(typeof(object).FullName));
//Go through the types and for each base type add any new derived types.
//Since Find returns a reference to a node within InputNode, the original
//node is modified when n is modified.
//AddChild checks for existence and only adds if new.
foreach (Type t in types)
{
if (t.BaseType != null && t.BaseType.FullName != null)
{
TreeNode n = InputNode.Find(t.BaseType.FullName);
if (n != null)
{
n.AddChild(new TreeNode(t));
} //if
} //if
} //foreach
} //FillTree()