本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.Contains方法的具体用法?C# TreeNodeCollection.Contains怎么用?C# TreeNodeCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindNextNode
public static TreeNode FindNextNode( TreeNodeCollection nodes, TreeNode selected )
{
if( nodes != null && nodes.Count > 0 )
{
TreeNode node1 = ( selected == null ) ? nodes[0] : selected;
TreeNode backup = node1;
if( node1.Nodes.Count > 0 ) // if we have child the show it first
{
return node1.Nodes[0];
}
else
{
TreeNode node2 = node1;
while( node2 != null )
{
if( node2.Parent == null || nodes.Contains( node2 ) == true ) // if we on the top of tree
{
if( node2.Index < nodes.Count-1 ) // check can we select next node or not
{
return nodes[ node2.Index + 1 ];
}
else // we on the last node in tree
{
// if we on last child of tree node
if( node2 != backup ) return backup;
return node2;
}
}
else // if we have a parent node
{
node1 = node2.Parent;
if( node2.Index < node1.Nodes.Count-1 ) // can we select next node
{
return node1.Nodes[ node2.Index + 1 ];
}
else // go to the parent
{
node2 = node1;
}
}
}
}
}
return null;
}
示例2: IsChild
private static bool IsChild(TreeNodeCollection nodes, TreeNode node, int maxLevel)
{
if (nodes.Contains(node))
return true;
foreach (TreeNode n in nodes)
{
if (n.Level < maxLevel && IsChild(n.Nodes, node, NODE_LEVEL_CLASS))
return true;
}
return false;
}
示例3: FindPrevNode
public static TreeNode FindPrevNode( TreeNodeCollection nodes, TreeNode selected )
{
if( nodes != null && nodes.Count > 0 )
{
TreeNode node1 = ( selected == null ) ? nodes[0] : selected;
TreeNode backup = node1;
if( node1.Parent == null || nodes.Contains( node1 ) == true )
{
// if we not on first node
if( node1.Index > 0 && node1.Index < nodes.Count )
{
TreeNode node2 = nodes[ node1.Index - 1 ];
node1 = node2;
// find last child of new selected node
if( node2.Nodes.Count > 0 )
{
do
{
node1 = node1.Nodes[ node2.Nodes.Count - 1 ];
}
while( node1.Nodes.Count != 0 );
}
return node1;
}
else
{
return node1;
}
}
else
{
// if we are not a first child of parent
if( node1.Index > 0 && node1.Index < node1.Parent.Nodes.Count )
{
TreeNode node2 = node1.Parent.Nodes[ node1.Index - 1 ];
node1 = node2;
// find last child of new selected node
if( node2.Nodes.Count > 0 )
{
do
{
node1 = node1.Nodes[ node2.Nodes.Count - 1 ];
}
while( node1.Nodes.Count != 0 );
}
return node1;
}
else // first child of parent
{
return node1.Parent;
}
}
}
return null;
}