1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Private Sub UserForm_Initialize()
Dim NumCol As Integer, j As Integer
Dim NumLig As Integer, k As Integer
Dim Cell As Range
Dim nodx As Node
Dim Image1 As String, Image2 As String
'--- Spécifie les images qui s'affichent dans les noeuds.
'Les images doivent être dans le même répertoire que le classeur.
Image1 = ThisWorkbook.Path & "\redball.gif"
Image2 = ThisWorkbook.Path & "\grnarrow.gif"
'Supprime le contenu de l'ImageList
Me.ImageList1.ListImages.Clear
'chargement des images
Me.ImageList1.ListImages.Add 1, "Img1", LoadPicture(Image1)
Me.ImageList1.ListImages.Add 2, "Img2", LoadPicture(Image2)
'Associe les images au TreeView
Set Me.TreeView1.ImageList = Me.ImageList1
'---
'Boucle sur les éléments de la structure pour remplir le TreeView
For Each Cell In Feuil2.Range("A1:A" & Feuil2.Range("N65533").End(xlUp).Row)
NumCol = Cell.End(xlToRight).Column
NumLig = Cell.Row
If NumCol = 2 Then
TreeView1.Nodes.Add , , "maClé" & NumLig & NumCol, _
UCase(Feuil2.Cells(NumLig, NumCol)), "Img1", "Img1"
Else
k = Feuil2.Cells(NumLig, NumCol).Offset(0, -1).End(xlUp).Row
j = Feuil2.Cells(NumLig, NumCol).Offset(0, -1).Column
'S'il s'agit d'un membre de l'équipe:
'(Dans ce cas la colonne N contient la lettre "x")
If Feuil2.Cells(NumLig, 14) = "x" Then
TreeView1.Nodes.Add _
"maClé" & k & j, tvwChild, "maClé" & NumLig & NumCol, _
Feuil2.Cells(NumLig, NumCol), "Img2", "Img2"
Else
'S'il s'agit d'un titre de service:
TreeView1.Nodes.Add _
"maClé" & k & j, tvwChild, "maClé" & NumLig & NumCol, _
UCase(Feuil2.Cells(NumLig, NumCol)), "Img1", "Img1"
End If
End If
Next Cell
TreeView1.Style = 5
End Sub |
Partager