本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection.IndexOfKey方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.IndexOfKey方法的具体用法?C# TreeNodeCollection.IndexOfKey怎么用?C# TreeNodeCollection.IndexOfKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.IndexOfKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOrAdd
private TreeNode GetOrAdd(TreeNodeCollection aNodes, string aValue)
{
int idx = aNodes.IndexOfKey(aValue);
if (idx >= 0)
{
return aNodes[idx];
}
else
{
TreeNode node = aNodes.Add(aValue, aValue);
node.ExpandAll();
return node;
}
}
示例2: 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);
}