主要是用的默认的控件
private void loadTree()
{
DataSet ds = new DataSet();
ds = cn.Inquire("1=1");
if (ds.Tables[0].Rows.Count <= 0)
{
this.T编辑.Enabled = false;
this.T删除.Enabled = false;
}
treeList1.ClearNodes();
AddTree("0", null, ds);
treeList1.ExpandAll();
}
// 递归添加树的节点
public void AddTree(string ParentID,TreeNode pNode, DataSet ds)
{
TreeNode tt = null;
DataRow[] qy = ds.Tables[0].Select("[父节点]='" + ParentID + "'");
for (int i = 0; i < qy.Length; i++)
{
if (pNode == null)
{
tt = treeList11.Nodes.Add(qy[i]["TID"].ToString() + " " + qy[i]["类别名称"].ToString());
AddTree(qy[i]["TID"].ToString(), tt, ds);
continue;
}
tt = pNode.Nodes.Add(qy[i]["TID"].ToString() + " " + qy[i]["类别名称"].ToString());
AddTree(qy[i]["TID"].ToString(), tt, ds);
}
}