递归创建treeview

private void InitTree(TreeNode node, int pid)
{

for (int i = 0; i < dt1.Rows.Count; i++)
{
if (Convert.ToInt32(dt1.Rows[i]["pid"].ToString()) == pid)
{
TreeNode newNode = new TreeNode(dt1.Rows[i]["name"].ToString());
node.Nodes.Add(newNode);
InitTree(newNode, Convert.ToInt32(dt1.Rows[i]["id"].ToString()));
}
}

posted @ 2015-03-10 18:29  Asilan  阅读(185)  评论(0编辑  收藏  举报