当前位置: 首页>>代码示例>>C#>>正文


C# Forms.TreeNodeCollection类代码示例

本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection类的具体用法?C# TreeNodeCollection怎么用?C# TreeNodeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TreeNodeCollection类属于System.Windows.Forms命名空间,在下文中一共展示了TreeNodeCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: expandNamespace_function

        private void expandNamespace_function(TreeNodeCollection outNodes, string strSection, string strNamespace, XmlReader reader)
        {
            bool bContinue = reader.ReadToDescendant("function");
            while (bContinue)
            {
                NodeDocPythonFunction node = newnode(strSection, strNamespace, reader.GetAttribute("name"));
                outNodes.Add(node);

                bool bInstance = reader.GetAttribute("instance") == "true";
                node.bIsInstanceMethod = bInstance;
                string strSyntax = reader.GetAttribute("fullsyntax"); if (strSyntax != null && strSyntax != "") node.strFullSyntax = strSyntax;
                node.strDocumentation = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example

                if (this.emphasizeStaticness())
                {
                    if (!bInstance)
                    {
                        //change visible node text to emphasize static-ness
                        node.Text = node.strNamespacename + "." + node.strFunctionname;
                    }
                }
                bContinue = ReadToNextSibling(reader, "function");
            }

            reader.Close();
        }
开发者ID:downpoured,项目名称:lnzscript,代码行数:26,代码来源:DocumentationFromPythonXml.cs

示例4: ShowData

        internal void ShowData(TreeNodeCollection nodes)
        {
            var lst = getSelection(nodes);
            chart.Series.Clear();

            var logarithmic = btnLogarithmicScale.Checked;

            var area = chart.ChartAreas[0];
            area.AxisY.IsLogarithmic = logarithmic;

            var chartType = cboStyle.Text.AsEnum<SeriesChartType>(SeriesChartType.Spline);

            foreach(var sel in lst)
            {
                var series = chart.Series.Add( sel.m_Type.Name + "::" + sel.m_Source );
                series.ChartType = chartType;

                foreach(var d in sel.m_Data)
                {
                    var v = d.ValueAsObject;

                    if (logarithmic)
                    {
                        if (v is long) v = 1 +(long)v;
                        if (v is double) v = 1 +(double)v;
                    }
                    series.Points.AddXY(d.UTCTime, v );
                }
            }
        }
开发者ID:itadapter,项目名称:nfx,代码行数:30,代码来源:ChartForm.cs

示例5: LoadTagBlockValuesAsNodes

 private void LoadTagBlockValuesAsNodes(TreeNodeCollection treeNodeCollection, TagBlock block)
 {
     //Add this TagBlock (chunk) to the Nodes
     treeNodeCollection.Add(block.ToString());
     int index = treeNodeCollection.Count - 1;
     treeNodeCollection[index].ContextMenuStrip = chunkMenu;
     //Add the TagBlock (chunk) object to the Tag to let use edit it directly from the node
     treeNodeCollection[index].Tag = block;
     //Values might be null, dealio
     if (block.Values == null) return;
     foreach (Value val in block.Values)
     {
         //the Values can be a bunch of things, we only want the ones that are TagBlockArrays (reflexives)
         if (val is TagBlockArray)
         {
             treeNodeCollection[index].Nodes.Add(val.ToString());
             treeNodeCollection[index].Nodes[treeNodeCollection[index].Nodes.Count - 1].ContextMenuStrip = reflexiveMenu;
             //Add the TagBlockArray object (reflexive) to the Tag to let us edit it directly from the node
             treeNodeCollection[index].Nodes[treeNodeCollection[index].Nodes.Count - 1].Tag = val;
             //TagBlocks also might be null, dealio
             if ((val as TagBlockArray).TagBlocks == null) continue;
             foreach (TagBlock tagBlock in (val as TagBlockArray).TagBlocks)
             {
                 //Recurse
                 LoadTagBlockValuesAsNodes(treeNodeCollection[index].Nodes[treeNodeCollection[index].Nodes.Count - 1].Nodes, tagBlock);
             }
         }
     }
 }
开发者ID:kholdfuzion,项目名称:halo2x-sunfish,代码行数:29,代码来源:MainForm.cs

示例6: AddSourceNodeToRoot

        private void AddSourceNodeToRoot(Guid source, TreeNodeCollection coll)
        {
            var node = new TreeNode
                           {
                               Name = source.ToString(),
                               Text = source.ToString()
                           };

            node.ContextMenu = new ContextMenu(
                new[]
                    {
                        new MenuItem("Delete",
                                     (sender, args) =>
                                         {
                                             var senderNode = ((sender as MenuItem).Parent.Tag as TreeNode);
                                             if (senderNode.Nodes.Count > 0)
                                             {
                                                 MessageBox.Show("Nodes containing events cannot be deleted.");
                                                 return;
                                             }
                                             store.RemoveEmptyEventSource(Guid.Parse(node.Name));
                                             senderNode.Remove();
                                         }
                            )
                    }
                ) { Tag = node };

            coll.Add(node);

            var events = store.GetAllEvents(source);
            foreach (var evt in events)
            {
                AddEvtNodeToSourceNode(evt, node);
            }
        }
开发者ID:phillipknauss,项目名称:CqrsSiteEngine,代码行数:35,代码来源:EventStoreExplorer.cs

示例7: HoleAlleAusgewaehltenEmpfaengerIDs

 public static ArrayList HoleAlleAusgewaehltenEmpfaengerIDs(TreeNodeCollection pin_TreeNode)
 {
     // neue leere Arraylist
     ArrayList pout_AL = new ArrayList();
     // gehe durch alle enthaltenen Knoten
     if (pin_TreeNode.Count != 0)
     {
         foreach(TreeNode tn in pin_TreeNode)
         {
             // gehe durch alle in diesem enthaltenen Knoten Knoten
             if (tn.Nodes != null)
             {
                 ArrayList tmp = HoleAlleAusgewaehltenEmpfaengerIDs(tn.Nodes);
                 if (tmp != null)
                 {
                     // füge Rückgabewerte der aktuellen ArrayList hinzu
                     pout_AL.AddRange(tmp);
                 }
             }
             // prüfe, ob ein Tag-Value existiert
             if (tn.Tag != null)
                 // prüfe, ob das Element ausgewählt wurde
                 if(tn.Checked)
                 {
                     // hole die PelsObject.ID und speichere diese in der ArrayList
                     pout_AL.Add(((Cdv_pELSObject) tn.Tag).ID);
                 }
         }
     }
     else
     {
     }
     return pout_AL;
 }
开发者ID:BackupTheBerlios,项目名称:pels-svn,代码行数:34,代码来源:Cpr_Funk_AllgFkt.cs

示例8: FindNodeByFullPathInt

		internal TreeNode FindNodeByFullPathInt(TreeNodeCollection nodes, String fullPath)
		{
			int pathSep = fullPath.IndexOf(PathSeparator);
			String partPath;
			if (pathSep == -1)
				partPath = fullPath;
			else
				partPath = fullPath.Substring(0, pathSep);
			
			foreach (TreeNode node in nodes)
			{
				if (node.Text.Equals(partPath))
				{
					// We are at the bottom
					if (pathSep == -1)
						return node;
					String restPath = fullPath.Substring
						(PathSeparator.Length + pathSep);
					return FindNodeByFullPathInt(node.Nodes,
												restPath);
				}
			}
			// Not found
			return null;
		}
开发者ID:JohnnyBravo75,项目名称:SharpDevelop,代码行数:25,代码来源:TreeListView.cs

示例9: PopulateNodes

        private void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
        {
            if ((dt == null) || (dt.Rows.Count == 0))
                return;

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

            foreach (DataRow dr in dt.Rows)
            {
                string name = dr["CatHebrewName"].ToString().Trim();
                string id = dr["CatId"].ToString().Trim();
                TreeNode tn = new TreeNode();
                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,代码来源:Form_CategoriesManager.cs

示例10: GetNodeByPath

        /// <summary>
        /// Get node by path.
        /// </summary>
        /// <param name="nodes">Collection of nodes.</param>
        /// <param name="path">TreeView path for node.</param>
        /// <returns>Returns null if the node won't be find, otherwise <see cref="TreeNode"/>.</returns>
        public static TreeNode GetNodeByPath(TreeNodeCollection nodes, string path)
        {
            foreach (TreeNode currentNode in nodes)
            {
                if (Path.GetExtension(currentNode.FullPath) != string.Empty)
                {
                    continue;
                }

                if (currentNode.FullPath == path)
                {
                    return currentNode;
                }

                if (currentNode.Nodes.Count > 0)
                {
                    TreeNode treeNode = GetNodeByPath(currentNode.Nodes, path);

                    // Check if we found a node.
                    if (treeNode != null)
                    {
                        return treeNode;
                    }
                }
            }

            return null;
        }
开发者ID:123marvin123,项目名称:PawnPlus,代码行数:34,代码来源:TreeNode.cs

示例11: createProtocol

 private static void createProtocol(TreeNodeCollection tree, Block data)
 {
     Block temp = null;
     foreach (TreeNode t in tree)
     {
         if (t.Name.Equals("block"))
         {
             temp = data.addBlock(t.Text, t.ImageKey, t.SelectedImageKey);
             createProtocol(t.Nodes, temp);
         }
         else
         {
             if (t.Name.Equals("multi"))
             {
                 Field f = data.addField(t.Text, t.Name, "", t.SelectedImageKey);
                 string[] values = t.ImageKey.Split(';');
                 foreach (string s in values)
                 {
                     string[] pair = s.Split(':');
                     ((MultiField)f).addKey(pair[0], pair[1]);
                 }
             }
             else data.addField(t.Text, t.Name, t.ImageKey, t.SelectedImageKey);
         }
     }
 }
开发者ID:vicban3d,项目名称:Hackaton,代码行数:26,代码来源:Facade.cs

示例12: LoadWorkFlowClassSelectNode

        /// <summary>
        /// 选中装载流程类型
        /// </summary>
        /// <param name="key"></param>
        /// <param name="startNodes"></param>
        public static void LoadWorkFlowClassSelectNode(string key, TreeNodeCollection startNodes)
        {
            try
            {
                DataTable table = WorkFlowClass.GetChildWorkflowClass(key);

                
                foreach (DataRow row in table.Rows)
                {
                    WorkFlowClassTreeNode tmpNode = new WorkFlowClassTreeNode();
                    tmpNode.NodeId = row["WFClassId"].ToString();
                    tmpNode.ImageIndex = 0;
                    tmpNode.ToolTipText = "分类";
                    tmpNode.SelectedImageIndex = 0;
                    tmpNode.clLevel = Convert.ToInt16(row["clLevel"]);
                    tmpNode.Text = row["Caption"].ToString();
                    tmpNode.WorkflowFatherClassId = row["FatherId"].ToString();
                    tmpNode.Description = row["Description"].ToString();
                    tmpNode.MgrUrl = row["clmgrurl"].ToString();
                    tmpNode.NodeType = WorkConst.WORKFLOW_CLASS;
                    startNodes.Add(tmpNode);

                    

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:37,代码来源:WorkFlowClassTreeNode.cs

示例13: FillTreeView

        private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab)
        {
            if (nodeCollection != null && tab != null)
            {
                foreach (TabPage tabPage in tab.TabPages)
                {
                    TreeNode treeNode = new TreeNode(tabPage.Text);
                    if (!string.IsNullOrEmpty(tabPage.ImageKey))
                    {
                        treeNode.ImageKey = treeNode.SelectedImageKey = tabPage.ImageKey;
                    }
                    treeNode.Tag = tabPage;
                    nodeCollection.Add(treeNode);

                    foreach (Control control in tabPage.Controls)
                    {
                        if (control is TabControl)
                        {
                            FillTreeView(treeNode.Nodes, control as TabControl);
                            break;
                        }
                    }
                }
            }
        }
开发者ID:Edison6351,项目名称:ShareX,代码行数:25,代码来源:TabToTreeView.cs

示例14: FindNodeByObject

 internal static NodeBase FindNodeByObject(TreeNodeCollection treeNodeCollection, object obj)
 {
     foreach (NodeBase node in treeNodeCollection)
         if (node.Object == obj)
             return node;
     return null;
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:7,代码来源:TreeViewManager.cs

示例15: 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


注:本文中的System.Windows.Forms.TreeNodeCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。