2
ように私はこのようなタブ形式のテキストにツリービュー構造をエクスポートする必要があります。のC#のWinForms - 表示ツリー構造タブ形式のテキスト
node 1
child node 1.1
child node 1.1.1
child node 1.1.1.1
node 2
child node 2.1
child node 2.1.1
child node 2.1.1.1
...etc
私は、次の再帰的なルーチンを作成しました:
public static string ExportTreeNode(TreeNodeCollection treeNodes)
{
string retText = null;
if (treeNodes.Count == 0) return null;
foreach (TreeNode node in treeNodes)
{
retText += node.Text + "\n";
// Recursively check the children of each node in the nodes collection.
retText += "\t" + ExportTreeNode(node.Nodes);
}
return retText;
}
仕事をすることを望んでいますが、そうではありません。代わりに、ツリー構造を次のように出力します。
node 1
child node 1.1
child node 1.1.1
child node 1.1.1.1
node 2
child node 2.1
child node 2.1.1
child node 2.1.1.1
誰かがこれを手伝ってくれますか?どうもありがとう!
を変更し、これは私がそれを呼び出す方法です:あなたの関数にインデントパラメータを追加しますtextTree = TreeViewSearch.ExportTreeNode(tvSearchResults.Nodes)) ; – user2430797