Bonjour,
Je voudrais faire un bouton qui permet de créer automatiquement le treeview à partir d'un tableau donné en 3 étapes :
http://prntscr.com/7owk12
Je pourrai le faire manuellement mais c'est beaucoup trop long... et ne permettrai pas de changer les données.
Comment feriez vous pour que le treeview se développe automatiquement à partir de cette base là? (Avec des extensions de noeuds supplémentaire si on modifie le tableau?)
Merci de votre aide
Ps : J'ai déjà fais le treeview avec ce tableau manuellement sans m'en rendre compte ... ')
Mon code si sa en intéresse certains et faites pas trop gaffes aux commentaires, je les mets toujours n'importe comment, MERCI <3
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 Var Tempo_Noeud_Text : String; I, A, B, ID : Integer; RowCount, RowCountTempo, NOEUD_UN, NOEUD_Tempo : integer; Name_Noeud, Test : string; First_Noeud, Second_Noeud : Boolean; begin {Lire tableau} //Lit les Numéros parents ADORequete.Active:=false; ADORequete.SQL.Clear; ADORequete.SQl.Add('SELECT Branche FROM Branches_1_Parents'); ADORequete.Active:=true; {Tableau lu} //Nb de Ligne totales RowCountTempo := ADORequete.RecordCount;//Nombre total de données {Inits_Variables} First_Noeud := False; NOEUD_UN := 0; {GO} if(Arborescence.selected <> nil) then begin {Lire tableau} //Dans la boucle A ADORequete.Active:=false; ADORequete.SQL.Clear; ADORequete.SQl.Add('SELECT Parent FROM Branches_1_Parents');//Sélection le premier numéro ADORequete.Active:=true; NOEUD_Tempo := ADORequete.FieldByName('Parent').AsInteger; //Prend ppv 0 for A := 0 to RowCountTempo do //Jusqu'a MAX 12?? begin if(NOEUD_Tempo = NOEUD_UN) then //Si Premiere val lu = 0 begin NOEUD_Tempo := ADORequete.FieldByName('Parent').AsInteger; //Prend ppv 0 ADO_Name.Active:=false; // ADO_NAME POUR LE NOM ET ADOREQUETE POUR LE NUMERO ADO_Name.SQL.Clear; ADO_Name.SQl.Add('SELECT Branche FROM Branches_1_Parents where Parent ='''+NOEUD_Tempo.ToString+'''');//Sélection le premier numéro ADO_Name.Active:=true; Test := ADO_Name.FieldByName('Branche').Text; RowCount := ADO_Name.RecordCount;//le nombre de noeud à 0 {Le premier NOEUD} if(First_Noeud = false)then begin for I := 1 to RowCount do//Boucle pour 1 Noeud begin Label2.Caption := ADO_Name.FieldByName('Branche').AsString; Name_Noeud := ADO_Name.FieldByName('Branche').AsString; Arborescence.Items.AddChild(Arborescence.Selected,Name_Noeud); ADO_Name.Next; ADORequete.Next; end;//FINI LES PARENTS 0, PASSE à 1 First_Noeud := true;//Fini la construction de la base ADORequete.Next; NOEUD_Tempo := ADORequete.FieldByName('Parent').AsInteger; //NOEUD_Tempo := NOEUD_Tempo + 1; NOEUD_UN := NOEUD_UN + 1; end; {Le deuxième NOEUD} if(First_Noeud = true) then//Aprs que la base soit faites begin ADO_Name.Active:=false; // ADO_NAME POUR LE NOM ET ADOREQUETE POUR LE NUMERO ADO_Name.SQL.Clear; ADO_Name.SQl.Add('SELECT Branche FROM Branches_1_Parents where Parent ='''+NOEUD_Tempo.ToString+'''');//Sélection le premier numéro ADO_Name.Active:=true; // ADO_Name.FieldByName('Branche').Text; RowCount := ADO_Name.RecordCount;//On a 2 for I := 1 to RowCountTempo do begin ADO_ID.Active:=false; // ADO_NAME POUR LE NOM ET ADOREQUETE POUR LE NUMERO ADO_ID.SQL.Clear; ADO_ID.SQl.Add('SELECT ID FROM Branches_1_Parents');//Sélectionne l'ID ADO_ID.Active:=true; ID := ADO_ID.FieldByName('ID').AsInteger; ADO_ID.Next; test := ADO_ID.FieldByName('ID').ToString;//Revoir l'incrément auto ID, Now manuel if(ID = NOEUD_Tempo) then begin for B := 1 to RowCount do begin Arborescence.Items.AddChildFirst((Arborescence.Selected),ADO_Name.FieldByName('Branche').Text); ADO_Name.Next; ADO_ID.Next; end; ADORequete.Next; NOEUD_Tempo := ADORequete.FieldByName('Parent').AsInteger; NOEUD_UN := NOEUD_UN + 1;//??? end else begin ID := ID + 1; end; end; { for I := 1 to RowCount do//Boucle pour 1 Noeud begin ADO_ID.Active:=false; // ADO_NAME POUR LE NOM ET ADOREQUETE POUR LE NUMERO ADO_ID.SQL.Clear; ADO_ID.SQl.Add('SELECT ID FROM Branches_1_Parents');//Sélectionne l'ID ADO_ID.Active:=true; ID := ADO_ID.FieldByName('ID').AsInteger; // if(ID = Label2.Caption := ADO_Name.FieldByName('Branche').AsString; Name_Noeud := ADO_Name.FieldByName('Branche').AsString; Arborescence.Items.AddChild(Arborescence.Selected,Name_Noeud); ADO_Name.Next; ADORequete.Next; end;//FINI LES PARENTS 0, PASSE à 1 First_Noeud := true;//Fini la construction de la base ADORequete.Next; NOEUD_Tempo := ADORequete.FieldByName('Parent').AsInteger; //NOEUD_Tempo := NOEUD_Tempo + 1; NOEUD_UN := NOEUD_UN + 1; } end;//Fin If Second Noeud end else begin NOEUD_Tempo := NOEUD_Tempo + 1; //Si incrémentation discontinue NOEUD_UN := NOEUD_UN + 1;//... end; end; end; end;
Partager