Winform TreeList递归绑定树节点

/// <summary>
/// 绑定树目录
/// </summary>
/// <param name="parentId">父ID</param>
/// <param name="node">父节点</param>
private void BindTree(int parentId, TreeListNode parentNode)
{
StringBuilder sb = new StringBuilder();
sb.Append("select * from tbTree order by [Index]");
DataSet ds = DbHelperSQL.QueryDataSet(sb.ToString());
DataRow[] rows = ds.Tables[].Select("ParentID=" + parentId);
foreach (DataRow row in rows)
{
TreeListNode treeNode;
//添加根节点
if (parentNode == null)
{
treeNode = this.treeList1.AppendNode(new object[] { row["ConText"] }, null);
}
else
{
treeNode = parentNode.TreeList.AppendNode(new object[] { row["ConText"] }, parentNode);
}
BindTree(Convert.ToInt32(row["ID"]), treeNode);
treeNode.ExpandAll();
}
}
上一篇:03.WebView演练-iOS开发Demo(示例程序)源代码


下一篇:C++反汇编调试