当前位置: 首页>>代码示例>>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;未经允许,请勿转载。