/// <summary> // 增加子节点的子节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void orgTree_BeforeExpand(object sender, TreeViewCancelEventArgs e) { Cursor.Current = Cursors.WaitCursor; foreach (TreeNode node in e.Node.Nodes) { if (node.Nodes.Count == 0) { D01TableAdapter.FillByPID(XT2007DataSet.D01, node.Name); if (XT2007DataSet.D01.Rows.Count > 0) { foreach (XT2007DataSet.D01Row row in XT2007DataSet.D01.Rows) { TreeNode subNode = node.Nodes.Add(row.D0107, row.D0101); subNode.Name = row.D0107; subNode.ToolTipText = "(" + row.D0107 + ")" + row.D0101; } } } } Cursor.Current = Cursors.Default; }
/// <summary> // 填充组织树(初始),含根节点和跟节点的子节点 /// </summary> private void FillOrg() { try { D01TableAdapter.FillByTopOrg(XT2007DataSet.D01); TreeNode root = null; if (XT2007DataSet.D01 != null) { XT2007DataSet.D01Row r = XT2007DataSet.D01.Rows[0] as XT2007DataSet.D01Row; root = orgTree.Nodes.Add(r.D0107, r.D0101); //增加根组织 root.Name = r.D0107; root.ToolTipText = "(" + r.D0107 + ")" + r.D0101; } if (root != null) { D01TableAdapter.FillByPID(XT2007DataSet.D01, root.Name); if (XT2007DataSet.D01 != null) { foreach (XT2007DataSet.D01Row row in XT2007DataSet.D01) { TreeNode subNode = root.Nodes.Add(row.D0107, row.D0101); subNode.Name = row.D0107; subNode.ToolTipText = "(" + row.D0107 + ")" + row.D0101; } } } } catch (InvalidOperationException ex) { System.Diagnostics.Process p = System.Diagnostics.Process.Start("regsvr32.exe", " kdbole6.dll"); p.WaitForInputIdle();//等待执行注册命令完毕 } }