private void treeView1_NodeMouseDoubleClick(object sender, EventArgs e) { TreeNode node = this.treeView1.SelectedNode; ICDDiagnosisInfo diagnosisInfo = node.Tag as ICDDiagnosisInfo; if (diagnosisInfo != null && diagnosisInfo.IsLeaf) { this.InsertTermToDoc(node); } }
/// <summary> /// 插入指定节点到文档中 /// </summary> /// <param name="treeNode">TreeNode节点</param> private void InsertTermToDoc(TreeNode treeNode) { if (treeNode == null || treeNode.Tag == null) { return; } this.Update(); this.DialogResult = DialogResult.OK; ICDDiagnosisInfo diagnosisInfo = treeNode.Tag as ICDDiagnosisInfo; if (diagnosisInfo == null) { return; } this.szSelectedDiagnosis = diagnosisInfo.DiagnosisName; // this.MedDocCtrl.ImportTextData(treeNode.Text); }
/// <summary> /// 在指定节点处创建叶子节点 /// </summary> /// <param name="node"></param> /// <param name="info"></param> private void CreateGroupNode(TreeNode parentNode, ICDDiagnosisInfo info) { TreeNode leafNode = new TreeNode(); leafNode.Text = info.DiagnosisName; leafNode.Tag = info; leafNode.Name = info.DiagnosisCode; leafNode.ImageIndex = 0; leafNode.SelectedImageIndex = 0; if (parentNode != null) { parentNode.Nodes.Add(leafNode); } else { this.treeView1.Nodes.Add(leafNode); } }
/// <summary> /// 在指定节点处创建叶子节点 /// </summary> /// <param name="node"></param> /// <param name="info"></param> private void CreateLeafNode(TreeNode node, ICDDiagnosisInfo info) { TreeNode leafNode = new TreeNode(); leafNode.Text = info.DiagnosisName + string.Format("[{0}]", info.DiagnosisCode); leafNode.Tag = info; leafNode.Name = info.DiagnosisCode; leafNode.ImageIndex = 2; leafNode.SelectedImageIndex = 2; if (node != null) { node.Nodes.Add(leafNode); } else { this.treeView1.Nodes.Add(leafNode); } }
private void CreateGroupDiagnosis(TreeNode node, ICDDiagnosisInfo diagnosis) { TreeNode groupTreeNode = new TreeNode(); groupTreeNode.Text = diagnosis.DiagnosisName; groupTreeNode.Tag = diagnosis; groupTreeNode.Name = diagnosis.DiagnosisCode; groupTreeNode.ImageIndex = 0; groupTreeNode.SelectedImageIndex = 0; //创建下一级节点 List <ICDDiagnosisInfo> lstNextLevelNodes = new List <ICDDiagnosisInfo>(); DataAccess.GetICDDiagnosisAndGroupList(diagnosis.DiagnosisCode, ref lstNextLevelNodes); if (lstNextLevelNodes != null && lstNextLevelNodes.Count > 0) { foreach (ICDDiagnosisInfo nextNode in lstNextLevelNodes) { bool isCreated = groupTreeNode.Nodes.Find(nextNode.DiagnosisCode, false).Length > 0 ? true : false; if (!isCreated && nextNode.IsLeaf) { CreateLeafNode(groupTreeNode, nextNode); } else if (!isCreated) { CreateGroupNode(groupTreeNode, nextNode); } } } groupTreeNode.Collapse(); if (node != null) { node.Nodes.Add(groupTreeNode); } else { this.treeView1.Nodes.Add(groupTreeNode); } }
private void treeView1_AfterExpand(object sender, TreeViewEventArgs e) { this.treeView1.SelectedNode = e.Node; //图标更换 e.Node.ImageIndex = 1; e.Node.SelectedImageIndex = 1; //加载各节点的子节点 foreach (TreeNode node in e.Node.Nodes) { List <ICDDiagnosisInfo> lstGroupDiagnosis = new List <ICDDiagnosisInfo>(); ICDDiagnosisInfo diagnosis = node.Tag as ICDDiagnosisInfo; if (diagnosis == null || node.ImageIndex != 0) { continue; } DataAccess.GetICDDiagnosisAndGroupList(diagnosis.DiagnosisCode, ref lstGroupDiagnosis); if (lstGroupDiagnosis != null && lstGroupDiagnosis.Count > 0) { foreach (ICDDiagnosisInfo info in lstGroupDiagnosis) { if (node.Nodes.Find(info.DiagnosisCode, false).Length < 1) { if (info.IsLeaf) { //创建叶子节点 CreateLeafNode(node, info); } else { CreateGroupNode(node, info); } } } } } }