Bonjour,
J'essaye de construire un treeview depuis un table que je récupère depuis une base.
Voici les tables et leur relation : image en pièce jointe (relations.jpg)
Voici mon code que je teste sans succès depuis hier soir :
Je desirerai obtenir la chose suivante :
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 'Initialisation de la chaîne contenant l'instruction SQL Dim rqSql_Root As String = "SELECT * FROM Location ORDER BY Location_Name;" Dim rqSql_Nod1 As String = "SELECT Location_Name, Project_Name, Comentaire FROM Project " & _ "INNER JOIN (Location INNER JOIN EACB_flow ON Location.PK_Location = EACB_flow.FK_Location) " & _ "ON Project.PK_Project = EACB_flow.FK_Project;" 'Indiquer au Combobox d'afficher la table retournée de TableRqst Dim MyRoot As DataTable = TableRqst(rqSql_Root, "Location") Dim MyNode1 As DataTable = TableRqst(rqSql_Nod1, "Location") For Each RootRow As DataRow In MyRoot.Rows TheTreeview.Nodes.Add(RootRow.Item(1)) 'For Each Node1row As DataRow In MyNode1.Rows If interfaceNode Is Nothing OrElse interfaceNode.Text <> RootRow.Item(1) Then interfaceNode = rootNode.Nodes.Add(MyRoot.Rows.Item(1).ToString) interfaceNode.Nodes.Add(MyNode1.Rows.Item(1).ToString) 'Console.WriteLine(RootRow.Item(1)) End If Next RootRow
Location_Name 1
+ Project_Name 1 of Location_Name 1
+ Project_Name 2 of Location_Name 1
+ Project_Name 3 of Location_Name 1
Location_name 2
+ Project_Name 1 of Location_Name 2
+ Project_Name 2 of Location_Name 2
Location Name 3
+ Aucun Projet pour Location_Name 3
Je ne sais absolument pas comment y arriver.
Quelqu'un pourrait il me mettre sur la voie de la connaissance?
Merci d'avance
Anax
Partager