[C#] TreeView 내용 추가하기
C# 2007. 12. 7. 08:34 |string[] childString = { "byoung1", "byoung2", "byoung3" };
입력방법 #1
{
treeView1.Nodes.Clear();
treeView1.BeginUpdate();
foreach (string str in parentString)
{
TreeNode tn = treeView1.Nodes.Add(str);
foreach (string substr in childString)
{
tn.Nodes.Add(substr);
}
}
treeView1.EndUpdate();
}
입력방법 #2
{
treeView1.Nodes.Clear();
treeView1.BeginUpdate();
foreach (string str in parentString)
{
treeView1.Nodes.Add(str);
}
foreach (TreeNode tn in treeView1.Nodes)
{
foreach (string substr in childString)
{
tn.Nodes.Add(substr);
}
}
treeView1.EndUpdate();
}
입력방법 #3
{
treeView1.Nodes.Clear();
treeView1.BeginUpdate();
TreeNode tn = new TreeNode();
foreach (string str in childString)
{
tn.Nodes.Add(str);
}
foreach (string str in parentString)
{
TreeNode tnParent = treeView1.Nodes.Add(str);
}
treeView1.EndUpdate();
}