' le Treeview A_TRW1 est rempli à partir des données de la base
Set a = Sht_BASE.Range("A2").CurrentRegion
Set TVX = UF_Lecture.MultiPage1.PageArbo.A_TRW1
With A_TRW1.Nodes
.Clear
Tmod = "R"
Set nodX = .Add(, , Tmod, "Projet")
ii = 0
For nn = 2 To a.Rows.Count ' boucle pour chaque ligne
If a(nn, 1) <> Tmod Then
' création du noeud principal(parent) indice ii
ii = ii + 1
' nom du noeud de niveau 1
Tmod = a(nn, 1)
' créer le noeud parent Tmod et le déployer
Set nodX = .Add("R", tvwChild, "C" & ii, Expanded = True)
' rendre le noeud visible ( utile si la liste est plus grande que le TreeView)
nodX.EnsureVisible
jj = 0
End If
If a(nn, 1) = Tmod Then
' création du noeud secondaire(enfant) indice jj
jj = jj + 1 ' ii & jj = indice du noeud de niveau 2
Tpro = a(nn, 3) ' nom du noeud de niveau 2
' nota : le nom i&j est mis au format XXX&XXX pour éviter les doublons
Set nodX = A_TRW1.Nodes.Add("C" & ii, tvwChild, "D" & _
Format(ii, "000") & Format(jj, "000"), Tpro)
End If
Next nn
End With