これに似たxmlファイルがあります
<items>
<cla1>
<type1>
<unit>this is a unit</unit>
<title>this is a title</title>
<link></link>
</type1>
<type2>
<unit>this is a unit</unit>
<title>this is a title</title>
<link></link>
</type2>
</cla1>
<cla2>
<type1>
<title>this is a title</title>
<link></link>
</type1>
</cla2>
</items>
この情報を使用して、ツリービュー コントロールを次のように設定します。
(画像を追加できないので、ここにリンクがあります) http://i.imgur.com/cVRDhDR.png
name of cla
|____type1 value
| |____unit value
| |_____title value
|____type2 value
| |____unit value
| |_____title value
|
name of cla
|____type1 value
| |____title value
|
私のxml構造がこれを難しくしている可能性があることは理解していますが(これは初めてです)、物事が簡単になるのであれば、これを変更してもかまいません。探しているものを達成する方法についての提案をいただければ幸いです。これは私がすでに持っているもののサンプルです。私にはこれは過剰で非効率的であるように思えます。これを行うにはもっと簡単な方法があると感じています。
//this code is in a loop going over certain nodes and
//keeps going like this until it reaches the end
if (!treeView1.Nodes.ContainsKey(cla))
{ treeView1.Nodes.Add(cla, cla); }
if (!treeView1.Nodes[cla].Nodes.ContainsKey(type))
{
treeView1.Nodes[cla].Nodes.Add(type, type);
}
ありがとう