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


C# TreeNodeCollection.Add方法代碼示例

本文整理匯總了C#中System.Windows.Forms.TreeNodeCollection.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# TreeNodeCollection.Add方法的具體用法?C# TreeNodeCollection.Add怎麽用?C# TreeNodeCollection.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.TreeNodeCollection的用法示例。


在下文中一共展示了TreeNodeCollection.Add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: initTrvTree

        public void initTrvTree(TreeNodeCollection treeNodes, string strParentIndex, DataView dvList)
        {
            try
            {
                TreeNode tempNode;
                DataView dvList1;
                string currentNum;
                dvList1 = dvList;
                // select the datarow that it's parentcode is strParentIndex
                DataRow[] dataRows = dvList.Table.Select("parentCode ='" + strParentIndex + "'");
                foreach (DataRow dr in dataRows)
                {
                    tempNode = new TreeNode();
                    tempNode.Text = dr["bookTypeCode"].ToString() + "-"
                        + dr["bookTypeName"].ToString();
                    // tag property is save data about this treenode
                    tempNode.Tag = new treeNodeData(dr["bookTypeCode"].ToString(),
                        dr["bookTypeName"].ToString(), dr["bookTypeExplain"].ToString(),
                        dr["currentCode"].ToString(), dr["parentCode"].ToString());

                    currentNum = dr["currentCode"].ToString();
                    treeNodes.Add(tempNode);
                    // call rucursive
                    TreeNodeCollection temp_nodes = treeNodes[treeNodes.Count - 1].Nodes;
                    initTrvTree(temp_nodes, currentNum, dvList1);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("初始化TreeView失敗");
            }
        }
開發者ID:ATLgo,項目名稱:bookMis,代碼行數:32,代碼來源:bookTypeClass.cs

示例2: GetSubKey

 /// <summary>
 /// 獲取注冊表項的子節點,並將其添加到樹形控件節點中
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="rootKey"></param>
 public void GetSubKey(TreeNodeCollection nodes, RegistryKey rootKey)
 {
     if (nodes.Count != 0) return;
     //獲取項的子項名稱列表
     string[] keyNames = rootKey.GetSubKeyNames();
     //遍曆子項名稱
     foreach (string keyName in keyNames)
     {
     try
     {
     //根據子項名稱功能注冊表項
     RegistryKey key = rootKey.OpenSubKey(keyName);
     //如果表項不存在,則繼續遍曆下一表項
     if (key == null) continue;
     //根據子項名稱創建對應樹形控件節點
     TreeNode TNRoot = new TreeNode(keyName);
     //將注冊表項與樹形控件節點綁定在一起
     TNRoot.Tag = key;
     //向樹形控件中添加節點
     nodes.Add(TNRoot);
     }
     catch
     {
     //如果由於權限問題無法訪問子項,則繼續搜索下一子項
     continue;
     }
     }
 }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:33,代碼來源:FormExplorer.cs

示例3: PopulateNodes

        private void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
        {
            TreeNode tn = new TreeNode();

            if (dt == null)
                return;

            if (nodes == null)
            {
                tn.Text = "אין קטגוריות";
                tn.ToolTipText = "-1";
                nodes.Add(tn);
            }

            foreach (DataRow dr in dt.Rows)
            {
                string name = dr["CatHebrewName"].ToString();
                string id = dr["CatId"].ToString();
                tn.Text = name;
                tn.ToolTipText = id;
                try
                {
                    nodes.Add(tn);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }

                DataTable childDT = GetTableFromQuery(String.Format("select * FROM Table_LookupCategories WHERE ParentCatId='{0}'", id));
                PopulateNodes(childDT, tn.Nodes);
            }
        }
開發者ID:haimon74,項目名稱:KanNaim,代碼行數:33,代碼來源:Copy+of+Form_CategoriesManager.cs

示例4: Apply

 void Apply( TypeAnalied type, TreeNodeCollection tnc )
 {
     if ( type.Parent == null ) {
         foreach ( TreeNode v in tnc ) {
             if ( v.Text == type.Source.Namespace ) {
                 tnc = v.Nodes;
                 break;
             }
             if ( tnc.IndexOf( v ) == tnc.Count - 1 ) {
                 tnc = tnc.Add( type.Source.Namespace ).Nodes;
                 break;
             }
         }
         if ( tnc.Count == 0 )
             tnc = tnc.Add( type.Source.Namespace ).Nodes;
     }
     TreeNode node = new TreeNode( type.Source.Name );
     tnc.Add( node );
     foreach ( VariableAnalied var_ana in type.Variables )
         Apply( var_ana, node.Nodes );
     foreach ( MethodAnalied var_ana in type.Methods )
         Apply( var_ana, node.Nodes );
     foreach ( TypeAnalied typ_ana in type.Types )
         Apply( typ_ana, node.Nodes );
 }
開發者ID:VarocalCross,項目名稱:Varocal,代碼行數:25,代碼來源:AssemblyView.cs

示例5: AddDiretory

 void AddDiretory(string dir, TreeNodeCollection nodes)
 {
     try
     {
         foreach (string subdir in System.IO.Directory.GetDirectories(dir, "*", System.IO.SearchOption.TopDirectoryOnly))
         {
             TreeNode node = new TreeNode(System.IO.Path.GetFileName(subdir));
             AddDiretory(subdir, node.Nodes);
             nodes.Add(node);
         }
     }
     catch (Exception)
     {
     }
     try
     {
         foreach (string file in System.IO.Directory.GetFiles(dir, "*", System.IO.SearchOption.TopDirectoryOnly))
         {
             TreeNode node = new TreeNode(System.IO.Path.GetFileName(file));
             node.Name = file.Remove(0, 4);  // 最初の"bmp\"を取り除く
             nodes.Add(node);
         }
     }
     catch (Exception)
     {
     }
 }
開發者ID:mifumi323,項目名稱:CharaBox3,代碼行數:27,代碼來源:FormEdit.cs

示例6: PopulateExternalMembers

        public static void PopulateExternalMembers( IMemberRefResolutionScope decl, TreeNodeCollection nodes, bool red )
        {
            foreach ( MethodRefDeclaration externalMethod in decl.MethodRefs )
            {
                nodes.Add( new ExternalMethodTreeNode( externalMethod, red ) );
            }

            foreach ( FieldRefDeclaration externalField in decl.FieldRefs )
            {
                nodes.Add( new ExternalFieldTreeNode( externalField, red ) );
            }
        }
開發者ID:jogibear9988,項目名稱:ormbattle,代碼行數:12,代碼來源:ExternalFieldTreeNode.cs

示例7: AddRoutes

 private void AddRoutes(TreeNodeCollection collection, string path, string[] keywords, string[] metadata)
 {
     if (Directory.Exists(path)) {
         string[] directories = Directory.GetDirectories(path);
         foreach (string directory in directories) {
             TreeNode node = collection.Add(Path.GetFileName(directory));
             node.ImageKey = "folder";
             node.SelectedImageKey = "folder";
             string title = Path.GetFileNameWithoutExtension(directory);
             if (keywords.Length != 0) {
                 List<string> remaining = new List<string>();
                 foreach (string keyword in keywords) {
                     if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) < 0) {
                         remaining.Add(keyword);
                     }
                 }
                 AddRoutes(node.Nodes, directory, remaining.ToArray(), metadata);
             } else {
                 AddRoutes(node.Nodes, directory, keywords, metadata);
             }
         }
         string[] files = Directory.GetFiles(path);
         foreach (string file in files) {
             if (file.EndsWith(".csv", StringComparison.OrdinalIgnoreCase) | file.EndsWith(".rw", StringComparison.OrdinalIgnoreCase)) {
                 string title = Path.GetFileNameWithoutExtension(file);
                 bool add = true;
                 foreach (string keyword in keywords) {
                     add = false;
                     foreach (string tag in metadata) {
                         if (tag.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) {
                             add = true;
                             break;
                         }
                     }
                     if (!add) {
                         if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) {
                             add = true;
                         } else {
                             break;
                         }
                     }
                 }
                 if (add) {
                     TreeNode node = collection.Add(title);
                     node.Tag = file;
                     node.ImageKey = "route";
                     node.SelectedImageKey = "route";
                 }
             }
         }
     }
 }
開發者ID:openbve,項目名稱:OpenBVE,代碼行數:52,代碼來源:formMain.Start.cs

示例8: PopulateMethod

 private void PopulateMethod(TreeNodeCollection c, Method m) {
   c.Add(new TreeNode(m.RestPath));
   c.Add(new TreeNode(m.RpcName));
   c.Add(new TreeNode(m.HttpMethod));
   TreeNode n = new TreeNode("Parameters");
   c.Add(n);
   c = n.Nodes;
   if (m.Parameters != null) {
     foreach (KeyValuePair<string, Parameter> p in m.Parameters) {
       PopulateParameter(c, p.Value);
     }
   }
 }
開發者ID:RishiKulshreshtha,項目名稱:google-api-dotnet-client,代碼行數:13,代碼來源:Form1.cs

示例9: InputFileAndDirectory

 /// <summary>
 /// 加載文件夾和文件的遞歸方法
 /// </summary>
 /// <param name="path"></param>
 /// <param name="tree"></param>
 private void InputFileAndDirectory(string path, TreeNodeCollection tree)
 {
     string[] directories = Directory.GetDirectories(path);
     foreach (var item in directories)//不用判斷是否有文件,如果沒有,foreach不會執行
     {
         TreeNode sonTrees = tree.Add(Path.GetFileName(item));
         InputFileAndDirectory(item, sonTrees.Nodes);
     }
     string[] files = Directory.GetFiles(path);
     foreach (var item in files)
     {
         tree.Add(Path.GetFileName(item));
     }
 }
開發者ID:RunningStudent,項目名稱:MyLearningCode_CSharp,代碼行數:19,代碼來源:Form1.cs

示例10: showParseNode

 private void showParseNode(PatternNode pattNode, TreeNodeCollection coll)
 {
     if (pattNode.Nodes.Count == 0) {
         coll.Add(pattNode.Text);
         return;
     }
     for (int i = 0; i < pattNode.Nodes.Count; i++) {
         PatternNode node = pattNode.Nodes[i];
         TreeNode treeNode = new TreeNode(node.Text + ":"+node.Releation.ToString()
             +":"+node.OneOrMore);
         coll.Add(treeNode);
         if (node.Nodes.Count != 0)
             showParseNode(node,treeNode.Nodes);
     }
 }
開發者ID:Loveice,項目名稱:love-ice,代碼行數:15,代碼來源:Form1.cs

示例11: Parser

        public bool Parser( ref TreeNodeCollection mNode, 
            byte [] PacketData ,
            ref int Index ,
            ref ListViewItem LItem)
        {
            TreeNode mNodex;
            string Tmp = "";
            //int k = 0;

            mNodex = new TreeNode();
            mNodex.Text = "TB ( Trans Bridging Protocol )";
            //mNodex.Tag = Index.ToString() + "," + Const.LENGTH_OF_ARP.ToString();
            //Function.SetPosition( ref mNodex , Index - 2 , 2 , false );

            /*if( ( Index + Const.LENGTH_OF_ARP ) >= PacketData.Length )
            {
                mNode.Add( mNodex );
                Tmp = "[ Malformed TB packet. Remaining bytes don't fit an TB packet. Possibly due to bad decoding ]";
                mNode.Add( Tmp );
                LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = Tmp;

                return false;
            }*/

            try
            {
                //k = Index - 2; mNodex.Nodes[ mNodex.Nodes.Count - 1 ].Tag = k.ToString() + ",2";

                LItem.SubItems[ Const.LIST_VIEW_PROTOCOL_INDEX ].Text = "TB";
                LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = "TB protocol";

                mNode.Add( mNodex );

            }
            catch( Exception Ex )
            {
                mNode.Add( mNodex );
                Tmp = "[ Malformed TB packet. Remaining bytes don't fit an TB packet. Possibly due to bad decoding ]";
                mNode.Add( Tmp );
                Tmp = "[ Exception raised is <" + Ex.GetType().ToString() + "> at packet index <" + Index.ToString() + "> ]";
                mNode.Add( Tmp );
                LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = "[ Malformed TB packet. Remaining bytes don't fit an TB packet. Possibly due to bad decoding ]";

                return false;
            }

            return true;
        }
開發者ID:dbose,項目名稱:raagahacker,代碼行數:48,代碼來源:PacketTB.cs

示例12: PopulateTree

 private void PopulateTree(Node currentNode, TreeNodeCollection parentsNodes)
 {
     TreeNode newNode = new TreeNode("[ " + currentNode.Type + "] " + currentNode.Value);
     parentsNodes.Add(newNode);
     foreach (Node child in currentNode.Children)
         PopulateTree(child, newNode.Nodes);
 }
開發者ID:Hammertime38,項目名稱:appium-dot-exe,代碼行數:7,代碼來源:InpsectorForm.cs

示例13: AddNodes

        private static void AddNodes(TreeNodeCollection treeNodes, RegexNode regexNode)
        {
            var treeNode = treeNodes.Add(
                regexNode.Id.ToString(CultureInfo.InvariantCulture),
                string.Format("{0} - {1}", regexNode.Pattern, regexNode.NodeType));

            if (regexNode is LeafNode)
            {
                return;
            }

            var wrapperNode = regexNode as WrapperNode;
            if (wrapperNode != null)
            {
                AddNodes(treeNode.Nodes, (wrapperNode).Child);
            }

            var containerNode = regexNode as ContainerNode;
            if (containerNode != null)
            {
                foreach (var child in (containerNode).Children)
                {
                    AddNodes(treeNode.Nodes, child);
                }
            }

            var alternation = regexNode as Alternation;
            if (alternation != null)
            {
                foreach (var choice in (alternation).Choices)
                {
                    AddNodes(treeNode.Nodes, choice);
                }
            }
        }
開發者ID:QuickenLoans,項目名稱:RegExpose,代碼行數:35,代碼來源:MainForm.cs

示例14: GetDirectories

        public void GetDirectories(TreeNode TreNode, TreeNodeCollection TreNodeCollection,string PathOfDir)
        {
            DirectoryInfo[] DirNames;

            //TreNode.SelectedImageIndex the index of image and this if to sure that
            // the image is not to rootnode and not to files so it will be to directory
            //and then open dir and get subdir and files
            if (TreNode.SelectedImageIndex!=0 && TreNode.SelectedImageIndex!=2)
            {
                try
                {
                    //to get directories
                    DirectoryInfo Directories = new DirectoryInfo(PathOfDir);
                    DirNames = Directories.GetDirectories();

                    foreach (DirectoryInfo DName in DirNames)
                    {
                        TreNode = new TreeNode(DName.Name,1,1);
                        TreNodeCollection.Add(TreNode);
                    }

                    //To get files from directory
                    GetFiles(TreNode, TreNodeCollection,PathOfDir);

                }
                catch (Exception w)
                {

                    MessageBox.Show(w.ToString());
                }
            }
        }
開發者ID:Tarek-AbdElfatah,項目名稱:TarekCodes,代碼行數:32,代碼來源:LoadTreeView.cs

示例15: BuildTree

 static void BuildTree(TreeNodeCollection nodes, Tree tree)
 {
     var node = new TreeNode { Text = tree.Token };
     nodes.Add(node);
     foreach (var subTree in tree)
         BuildTree(node.Nodes, subTree);
 }
開發者ID:sergey-podolsky,項目名稱:university,代碼行數:7,代碼來源:TreeViewer.cs


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