當前位置: 首頁>>代碼示例>>C#>>正文


C# TreeNodeCollection.Contains方法代碼示例

本文整理匯總了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;
        }
開發者ID:tiankongldp,項目名稱:MyTestApplication,代碼行數:50,代碼來源:TreeViewUtils.cs

示例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;
        }
開發者ID:jumpinjackie,項目名稱:fdotoolbox,代碼行數:13,代碼來源:FdoObjectExplorerExtender.cs

示例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;
        }
開發者ID:tiankongldp,項目名稱:MyTestApplication,代碼行數:61,代碼來源:TreeViewUtils.cs


注:本文中的System.Windows.Forms.TreeNodeCollection.Contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。