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


C# TreeNodeCollection.ContainsKey方法代码示例

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


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

示例1: CheckNodeIfPathExists

 static void CheckNodeIfPathExists(TreeNodeCollection nodes, string path)
 {
     var parts = path.Split(new[]{'\\'}, 2);
     var key = parts[0];
     if (!nodes.ContainsKey(key)) return;
     if (parts.Length == 1)
         nodes[key].Checked = true;
     else
     {
         nodes[key].Expand();
         CheckNodeIfPathExists(nodes[key].Nodes, parts[1]);
     }
 }
开发者ID:CamiloBernal,项目名称:reportsync,代码行数:13,代码来源:ReportSync.cs

示例2: populateTreeControl

		private void populateTreeControl(XmlNode document, TreeNodeCollection nodes)
		{
			// Dictionary<string, TreeNode> aNodeNames = new Dictionary<string, TreeNode>();
			foreach (System.Xml.XmlNode node in document.ChildNodes)
			{
				string text = node.Name;
				if (text == cstrExtraWhitespace)
					continue;

				text = String.Format(cstrElementFormat, text);

				if (node.Value != null)
					text += String.Format(" = [{0}]", node.Value);

				TreeNode thisBranch = null;
				string strPrefix = String.IsNullOrEmpty(node.Prefix) ? cstrDefaultNameSpaceAbrev : node.Prefix;
				if (!nodes.ContainsKey(node.Name))
				{
					thisBranch = nodes.Add(node.Name, text);	// do it once
					thisBranch.Tag = strPrefix;
					if (!m_mapPrefix2NamespaceURI.ContainsKey(strPrefix) && !String.IsNullOrEmpty(node.NamespaceURI))
						m_mapPrefix2NamespaceURI.Add(strPrefix, node.NamespaceURI);
				}
				else
				{
					thisBranch = nodes[node.Name];
					System.Diagnostics.Debug.Assert(strPrefix == (string)thisBranch.Tag);
				}

				// if there are any attributes for this branch/node, then put them in as children
				if ((node.Attributes != null) && (node.Attributes.Count > 0))
				{
					foreach (XmlAttribute attr in node.Attributes)
					{
						TreeNodeCollection tc = thisBranch.Nodes;
						if (!tc.ContainsKey(attr.Name))
						{
							int nNumAttrs = GetAttrCount(tc);
							string strAttrKeyValue = String.Format("{0}[{1}] = [{2}] ", cstrAttributeLabel, attr.Name, attr.Value);
							TreeNode newAttr = thisBranch.Nodes.Insert(nNumAttrs, attr.Name, strAttrKeyValue);
						}
					}
				}

				// iterate to the children of thisBranch
				populateTreeControl(node, thisBranch.Nodes);
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:48,代码来源:XMLViewForm.cs

示例3: Checker

        public bool Checker(TreeNodeCollection nodes, string key, ref string path)
        {
            bool result = false;
            if (nodes.Count > 0)
                if (!nodes.ContainsKey(key))
                    foreach (TreeNode node in nodes)
                    {
                        path += " " + node.Name;
                        bool t = Checker(node.Nodes, key, ref path);
                        if (t) { result = t; break; }
                        else path = path.Remove(path.Length - 1 - node.Name.Length);

                    }
                else { result = true; path += " " + key; }
            else result= false;
            return result;
        }
开发者ID:LaceUpAlive,项目名称:TreeBuilder,代码行数:17,代码来源:TreeBuilder.cs

示例4: BuildTree

        private void BuildTree(DirectoryInfo directoryInfo, TreeNodeCollection addInMe)
        {
            TreeNode curNode = null;
            if (addInMe.ContainsKey(directoryInfo.FullName) == false)
                curNode = addInMe.Add(directoryInfo.FullName, directoryInfo.Name);
            else
                curNode = addInMe.Find(directoryInfo.FullName, false)[0];

            foreach (FileInfo file in directoryInfo.GetFiles())
            {
                if (curNode.Nodes.ContainsKey(file.FullName) == false)
                {
                    curNode.Nodes.Add(file.FullName, file.Name);
                }
            }
            foreach (DirectoryInfo subdir in directoryInfo.GetDirectories())
            {
                BuildTree(subdir, curNode.Nodes);
            }
        }
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:20,代码来源:Form1.cs

示例5: checkNodeIfPathExists

 private void checkNodeIfPathExists(TreeNodeCollection nodes, string path)
 {
     var parts = path.Split(new char[] { '\\' }, 2);
     var key = parts[0];
     if (nodes.ContainsKey(key))
     {
         if (parts.Length == 1)
         {
             nodes[key].Checked = true;
         }
         else
         {
             nodes[key].Expand();
             checkNodeIfPathExists(nodes[key].Nodes, parts[1]);
         }
     }
 }
开发者ID:CarlosSolrac,项目名称:ReportSync-2,代码行数:17,代码来源:ReportSync.cs

示例6: FillSubNodes

 private void FillSubNodes(TreeNodeCollection nodes, PropertyInfo fileInfo)
 {
     // Удаляем из полного пути путь к указанной директории для перебора поддиректорий
     var nameDirs = fileInfo.FullName.Remove(0, _workDirLength).TrimStart('\\', '/').Split('\\', '/');
     if (string.IsNullOrEmpty(nameDirs[0]))
     {
         // Игнорируем дерикторию указанную для перебора поддиректорий
         return;
     }
     foreach (var name in nameDirs)
     {
         // Если в коллекции узлов нет указанного узла, то добавляем
         if (!nodes.ContainsKey(name))
         {
             var indexImg = fileInfo.IsFile ? 2 : 0;
             var indexSelectImg = fileInfo.IsFile ? 3 : 1;
             TreeNode node = new TreeNode(name, indexImg, indexSelectImg)
             {
                 Name = name,
                 Tag = fileInfo
             };
             
             nodes.Add(node);
         }
         else // иначе - переходим на дочерний уровень
         {
             nodes = nodes[name].Nodes;
         }
     }
 }
开发者ID:AlexRelax,项目名称:TestTasks-FileManager,代码行数:30,代码来源:Main.cs

示例7: addCategoryToTreeNodeCollection

 private static void addCategoryToTreeNodeCollection(String sCategoryText, String sCategoryName,
                                                     ref TreeNodeCollection tncTargetTreeNodeCollection,
                                                     Object oTreeNodeTag)
 {
     if (sCategoryName == "")
         return;
     if (false == tncTargetTreeNodeCollection.ContainsKey(sCategoryName))
     {
         tncTargetTreeNodeCollection.Add(O2Forms.newTreeNode(sCategoryText, sCategoryName, 1, oTreeNodeTag));
     }
     tncTargetTreeNodeCollection = tncTargetTreeNodeCollection[sCategoryName].Nodes;
 }
开发者ID:SiGhTfOrbACQ,项目名称:O2.FluentSharp,代码行数:12,代码来源:ascx_FunctionsViewer.Controllers.cs

示例8: GetOrCreateNode

 private static TreeNode GetOrCreateNode(TreeNodeCollection parentNodes, string key) {
   TreeNode node = null;
   if (parentNodes.ContainsKey(key)) {
     node = parentNodes[key];
   } else {
     node = parentNodes.Add(key, key);
   }
   return node;
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:9,代码来源:ProgrammableOperatorView.cs

示例9: GetNode

        TreeNode GetNode(string key, TreeNodeCollection nodes)
        {
            TreeNode n = null;
              if (nodes.ContainsKey(key))
            n = nodes[key];
              else
              {
            foreach (TreeNode tn in nodes)
            {
              n = GetNode(key, tn.Nodes);
              if (n != null) break;
            }
              }

              return n;
        }
开发者ID:aczarno,项目名称:StickMagik,代码行数:16,代码来源:ModelComponentsWindow.cs

示例10: CreateNodes

 private void CreateNodes(TreeNodeCollection treeNodeCollection, string[] parts, int index, ref string parent)
 {
     if (!treeNodeCollection.ContainsKey(parts[index]))
     {
         string extension = Path.GetExtension(parts[index]);
         ResourceTreeNode node;
         switch (extension)
         {
             case "":
                 node = new FolderTreeNode();
                 node.Text = Path.ChangeExtension(parts[index], null);
                 node.Name = parts[index];
                 string path = string.Empty;
                 for (int i = 0; i <= index; i++)
                     path = Path.Combine(path, parts[i]);
                 node.Path = Path.Combine(parent, path);
                 treeNodeCollection.Add(node);
                 break;
             case Sunfish.Tag.Path.Extension:
                 node = new ClassTreeNode();
                 node.Text = Path.ChangeExtension(parts[index], null);
                 node.Name = parts[index];
                 path = string.Empty;
                 foreach (string s in parts)
                     path = Path.Combine(path, s);
                 node.Path = Path.Combine(parent, path);
                 treeNodeCollection.Add(node);
                 break;
         }
     }
     if (parts.Length > index + 1)
         CreateNodes(treeNodeCollection[treeNodeCollection.IndexOfKey(parts[index])].Nodes, parts, index + 1, ref parent);
 }
开发者ID:kholdfuzion,项目名称:halo2x-sunfish,代码行数:33,代码来源:MainForm.cs

示例11: FindNode

 public TreeNode FindNode(TreeNodeCollection nodes, string key)
 {
     if (nodes.ContainsKey(key)) return nodes[key];
     else return null;
 }
开发者ID:sagar1589,项目名称:Delta.Cryptography,代码行数:5,代码来源:TreeViewExpandedStateSerializer.cs


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