winfrom ViewTree 生成树节点
public void AddRootNode()
{
tv_SystemTree.Nodes.Clear();
foreach (Model_SoftSystem item in softSystem.GetSoftSystemList())
{
TreeNode rootNode = tv_SystemTree.Nodes.Add(item.SystemName); //根节点
rootNode.Tag = item.SystemID;
SystemTree system = new SystemTree();
system.TreeNodeID = item.SystemID.ToString();
system.SystemName = item.SystemName;
AddChildNode(rootNode, system);
}
}
private void AddChildNode(TreeNode rootNode, SystemTree system)
{
List<SystemTree> tree = systemTree.GetSystemTreeInfoList();
if (tree.Count > 0)
{
foreach (SystemTree item in tree)
{
if (system.TreeNodeID == item.TreeParentID)
{
TreeNode nd = new TreeNode();
nd.Tag = item.TreeNodeID;
nd.Text = item.SystemName;
rootNode.Nodes.Add(nd);
AddChildNode(nd, item);
}
}
}
}