c# winfom从0学习开发开发OA、BPM工作流程与自定义表单系统(二)部门树形结构和下拉框的结构设计
具体的代码
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OA.Dal { public class DepartmentHelper { private static string toadd = "├"; public static void LoadDepartment(ComboBox cbDepartment, TreeView treeView) { ArrayList list = new ArrayList(); treeView.Nodes.Clear(); var departmentList = Bll.Bll_oa_department.GetDataByParentID(0); foreach (var u in departmentList) { int typeId = u.id; string typeName = u.name; TreeNode node = new TreeNode(); node.Text = Convert.ToString(typeName); node.Name = Convert.ToString(typeId); treeView.Nodes.Add(node); list.Add(new System.Collections.DictionaryEntry(typeId, toadd + typeName)); BindData(typeId, node, list); } treeView.ExpandAll(); cbDepartment.DataSource = list; cbDepartment.DisplayMember = "Value"; cbDepartment.ValueMember = "Key"; } private static void BindData(int parentId, TreeNode parentNode, ArrayList list) { var departmentList = Bll.Bll_oa_department.GetDataByParentID(parentId); foreach (var u in departmentList) { int typeId = u.id; string typeName = u.name; TreeNode node = new TreeNode(); node.Text = Convert.ToString(typeName); node.Name = Convert.ToString(typeId); parentNode.Nodes.Add(node); toadd += "┴"; list.Add(new System.Collections.DictionaryEntry(typeId, toadd + typeName)); BindData(typeId, node, list); toadd = toadd.Substring(0, toadd.Length - 1); } } } }
标签:node,typeId,toadd,自定义,c#,list,System,using,下拉框 From: https://www.cnblogs.com/cxyyn/p/17743915.html