Re : treeview
Re tototiti
merci pour cet exemple qui prouve que je ne suis qu'un petit scarabée et surtout dans le treeview...
Par contre, je vois bien que ton code fonctionne (vu la photo), par contre, je ne sais pas comment modifier le mien. Je te tjoints le code de mon userform au complet :
Dim mclsFormChanger As CFormChanger
Dim tw As MSComctlLib.TreeView
Dim Base, n
Dim NumAetL
Dim DerlistAetL
Private Sub UserForm_Activate()
Set mclsFormChanger = New CFormChanger
'Initialise to be like a 'standard' userform
mclsFormChanger.ShowTaskBarIcon = True
mclsFormChanger.ShowMinimizeBtn = True
'Set the form changer to change this userform
Set mclsFormChanger.Form = Me
End Sub
Private Sub UserForm_Initialize()
Exemple.Visible = False
Label2.Visible = False
Appliquer.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
CommandButton1.Visible = False
If Worksheets("Introduction").Cells(1, 1).Value = Worksheets("ADMINISTRATION").Cells(2, 1).Value Then
F_Tree_Recursif1.Width = 716
Else
F_Tree_Recursif1.Width = 534
End If
'Dictionnaire du treeview
Dim Niveau_0
Dim NiveauInf
Worksheets("BD").Select
NumAetL = Worksheets("BD").Range("A65000").End(xlUp).Row
Niveau_0 = "0"
NiveauInf = Application.VLookup(Niveau_0, Range("A2:F" & NumAetL), 2, False)
Set tw = Me.MonArbre
n = Range("A2:F" & NumAetL).Rows.Count
Base = Range("A2:F" & NumAetL)
'tw.Nodes.Add(noeud_père,twchild,création_noeud_courant,libellé_noeud)
tw.Nodes.Add(, , "NoeudMat" & Niveau_0, NiveauInf).Expanded = True ' Racine arbre
vpersonnes Niveau_0
End Sub
Sub vpersonnes(parent) ' procédure récursive
Dim i, k, temp
For i = 2 To n
k = Len(Base(i, 1))
If k = 1 Then temp = "0" Else temp = Left(Base(i, 1), k - 2)
If temp = "" Then temp = "0"
If temp = parent Then
tw.Nodes.Add("NoeudMat" & parent, tvwChild, "NoeudMat" & Base(i, 1), Base(i, 1) & ") " & Base(i, 2)).Expanded = False
vpersonnes Base(i, 1)
End If
Next i
End Sub
Private Sub MonArbre_NodeClick(ByVal Node As MSComctlLib.Node)
'Recherche treeview
Dim i
For i = 1 To 30000
If MonArbre.SelectedItem = Worksheets("BD").Cells(i, 2).Value Then
If Worksheets("BD").Cells(i, 4).Value = "" Then Label4.Visible = False Else Label4.Visible = True
If Worksheets("BD").Cells(i, 5).Value = "" Then Label5.Visible = False Else Label5.Visible = True
Me.Explication = Worksheets("BD").Cells(i, 3).Value
Me.Exemple = Worksheets("BD").Cells(i, 4).Value
Me.Appliquer = Worksheets("BD").Cells(i, 5).Value
Label1.Visible = True
Exemple.Visible = False
Label2.Visible = False
Appliquer.Visible = False
Label3.Visible = False
End If
Next i
End Sub
De plus tu me dis dans ton 1er post de tester ton outil organiser ses codes VBA, j'ai cliqué dessus, mais rien...
Cordialement
hidozo