youxi123_: 代码有问题啊兄弟,用你的代码调试了半天[code=plain] private void AddTreeNode(string parentid,TreeNode pNode, TreeView tv, string parenid = "parentId", string showname = "C_NAME", string key = "C_ID") { TreeNode tn1 = new TreeNode(); DataView dv = new DataView(dt1); = $"{parenid}={parentid}"; foreach (DataRowView drv in dv) { if (pNode == null) { tn1 = new TreeNode(); = drv[showname].ToString(); = drv[key].ToString(); (tn1); = $"{parenid}={drv[key].ToString()}"; if ( > 0) { AddTreeNode(drv[key].ToString(), tn1, tv, parenid, showname, key); } } else { TreeNode tn2 = new TreeNode(); = drv[showname].ToString(); = drv[key].ToString(); (tn2); [/code]
MySQL数据库查找多个字段值全部相同的记录
TreeView动态绑定数据库显示数据