private void m_arbreResultat_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (OnDemandeAffichageNoeud != null && e.Node != null) { TreeNode node = e.Node; CNoeudCheminResultatRechercheObjetAvecParents noeudEnCours = null; while (node != null) { CArbreResultatRechercheObjet arbre = node.Tag as CArbreResultatRechercheObjet; if (arbre == null)//L'item n'est pas un arbre, stop la remontée { break; } INoeudCheminResultatRechercheObjet noeud = null; if (arbre != null) { noeud = arbre.Noeud; } if (noeud != null) { noeudEnCours = new CNoeudCheminResultatRechercheObjetAvecParents(noeud, noeudEnCours); } node = node.Parent; } if (noeudEnCours != null) { OnDemandeAffichageNoeud(noeudEnCours); } } }
//----------------------------------------------------------------------------- private void FillNodes(TreeNodeCollection nodes, CArbreResultatRechercheObjet arbre) { //Ajoute les branches de l'arbre foreach (CArbreResultatRechercheObjet branche in arbre.Branches) { nodes.Add(CreateNodeBranche(branche)); } }
private void CWndArbreResultatRequete_BeforeExpand(object sender, TreeViewCancelEventArgs e) { TreeNode node = e.Node; if (node.Nodes.Count == 1 && node.Nodes[0].Tag == null) { CArbreResultatRechercheObjet arbre = node.Tag as CArbreResultatRechercheObjet; node.Nodes.Clear(); if (arbre != null) { FillNodes(node.Nodes, arbre); } } }
//----------------------------------------------------------------------------- private TreeNode CreateNodeBranche(CArbreResultatRechercheObjet branche) { TreeNode node = new TreeNode(branche.Noeud.LibelleNoeudCheminResultatRechercheObjet); node.Tag = branche; if (branche.Branches.Length > 0) { node.Nodes.Add(new TreeNode("")); } int nIndex = 0; if (branche.Branches.Count() == 0) { nIndex = 1; } node.ImageIndex = nIndex; node.SelectedImageIndex = nIndex; return(node); }