0

問題:

以下のスクリーンショットでは、ノード300-9885-00Xとその TreeNodeCollection (赤い四角) が表示されています。少し下に、300-9885-00Xもう一度見つけます。以前に見つけた TreeNodeCollection をそのノードに挿入したいのです...

ツリービュー ノード


背景情報

AutoCAD/SolidEdge アセンブリを通過する再帰プログラムがあります。ドキュメントを開き、アセンブリとその子などを(再帰的に)出力します...

  • 緑色は印刷されていることを意味します
  • オレンジ色は以前に印刷されたことを意味するため、再度印刷する必要はありません...

質問:

既存の TreeNodeCollectionTreeNodeに挿入するにはどうすればよいですか?

知っている:

  1. TreeNodeCollection の場所
  2. コレクションを挿入したいノードの場所

次の変数TreeNodesには、私のコレクションが含まれています。テキストを追加するには、コレクションをループする必要がありますか? TreeCollectionAdd エラー

4

2 に答える 2

0
// Get the '_NodesCollection' from the '_parentNode' TreeNode.
TreeNodeCollection _Nodes = _parentNode.FirstNode.Nodes;

// Create an array of 'TreeNodes'.
TreeNode[] Nodes = new TreeNode[_Nodes.Count];

// Copy the tree nodes to the 'Nodes' array.
_Nodes.CopyTo(Nodes, 0);

// Remove the First Node & Children from the ParentNode.
_parentNode.Nodes.Remove(_parentNode.FirstNode);

// Remove all the tree nodes from the '_parentNode' TreeView.
_parentNode.Nodes.Clear();

// Add the 'Nodes' Array to the '_parentNode' ParentNode.
_parentNode.Nodes.AddRange(Nodes);

// Add the Child Nodes to the TreeView Control
TvMap.Nodes.Add(_parentNode);
于 2015-08-22T20:25:13.607 に答える