salut,

je viens par cette présente pour demander un peu d'aide à propos des treeview je developpe une appli winform là j'arrive pas à remplir mon treeview qui doit avoir 4 niveau je vous envoie ce que j'ai fait, j'implore votre indulgence car je suis UN GRAND DÉBUTANT

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    Dim DSNWind As DataSet

    Dim CNwind As New SqlClient.SqlConnection("....")

    Dim DACI1 As New SqlClient.SqlDataAdapter("SELECT IMP_CODE, IMP_NOM, TACHE.CODEFACIAL, TACHE.LIBELLE  FROM CI" _
& " inner join Tache on CI.TACHE_ID = TACHE.ID WHERE NIVEAU = 1", CNwind)

    Dim DACI2 As New SqlClient.SqlDataAdapter("SELECT IMP_CODE, IMP_NOM, TACHE.CODEFACIAL, TACHE.LIBELLE  FROM CI" _
    & " inner join Tache on CI.TACHE_ID = TACHE.ID WHERE NIVEAU = 2", CNwind)

    Dim DACI3 As New SqlClient.SqlDataAdapter("SELECT IMP_CODE, IMP_NOM, TACHE.CODEFACIAL, TACHE.LIBELLE  FROM CI" _
  & " inner join Tache on CI.TACHE_ID = TACHE.ID WHERE NIVEAU = 3", CNwind)

    Dim DACI4 As New SqlClient.SqlDataAdapter("SELECT IMP_CODE, IMP_NOM, TACHE.CODEFACIAL, TACHE.LIBELLE  FROM CI" _
  & " inner join Tache on CI.TACHE_ID = TACHE.ID WHERE NIVEAU = 4", CNwind)



    CNwind.Open()
'ça saute à partir d'ici

    DACI1.Fill(DSNWind, "chargerCi1")
    DACI2.Fill(DSNWind, "chargerCi2")
    DACI3.Fill(DSNWind, "chargerCi3")
    DACI4.Fill(DSNWind, "chargerCi4")

    CNwind.Close()


    'Création des data relation afin e simplifier la relation entre la table CI et la table Tache
    DSNWind.Relations.Add("_CI1", DSNWind.Tables("chargerCi1").Columns("TACHE_ID"), DSNWind.Tables("TACHE").Columns("ID"))
    DSNWind.Relations.Add("_CI2", DSNWind.Tables("chargerCi2").Columns("TACHE_ID"), DSNWind.Tables("TACHE").Columns("ID"))
    DSNWind.Relations.Add("_CI3", DSNWind.Tables("chargerCi3").Columns("TACHE_ID"), DSNWind.Tables("TACHE").Columns("ID"))
    DSNWind.Relations.Add("_CI4", DSNWind.Tables("chargerCi4").Columns("TACHE_ID"), DSNWind.Tables("TACHE").Columns("ID"))
  '''''''''''''''''''''''
    TreeViewTache.Nodes.Clear()
    Dim i, n As Integer
    Dim parentrow As DataRow
    Dim ParentTable As DataTable
    ParentTable = DSNWind.Tables("chargerCi1")

    For Each parentrow In ParentTable.Rows
      Dim parentnode As TreeNode
      parentnode = New TreeNode(parentrow.Item(0))
      TreeViewTache.Nodes.Add(parentnode)



      ''''populate child'''''
      '''''''''''''''''''''''
      Dim childRow As DataRow
      Dim childNode As TreeNode
      childNode = New TreeNode()
      For Each childRow In parentrow.GetChildRows("_CI1")
        childNode = parentnode.Nodes.Add(childRow(0) & " " & childRow(1) & " " & childRow(2) & " " & childRow(3))
        childNode.Tag = childRow("TACHE_ID")

        ''''populate child2''''
        ''''''''''''''''''''''''''
        Dim childRow2 As DataRow
        Dim childNode2 As TreeNode
        childNode2 = New TreeNode()
        For Each childRow2 In childRow.GetChildRows("_CI2")
          childNode2 = childNode.Nodes.Add(childRow2(0) & " " & childRow(1) & " " & childRow(2))
          childNode2.Tag = childRow("TACHE_ID")



          ''''populate child3''''
          ''''''''''''''''''''''''''
          Dim childRow3 As DataRow
          Dim childNode3 As TreeNode
          childNode3 = New TreeNode()
          For Each childRow3 In childRow.GetChildRows("_CI3")
            childNode3 = childNode.Nodes.Add(childRow3(0) & " " & childRow(1))
            childNode3.Tag = childRow("TACHE_ID")

            ''''populate child4''''
            ''''''''''''''''''''''''''
            Dim childRow4 As DataRow
            Dim childNode4 As TreeNode
            childNode4 = New TreeNode()
            For Each childRow4 In childRow.GetChildRows("_CI4")
              childNode4 = childNode.Nodes.Add(childRow4(0))



              '''''''''''''''
            Next childRow4
          Next childRow3
        Next childRow2
      Next childRow
    Next parentrow