Treeview little help

elcazador
07-18-2003, 11:44 AM
hi thre, i hope someone help me
I fried my brains try to solve this. At work (i work in a manufacturing company) they want to get some program to represent the explosion of a product (products-parts-raw materials) something like this

.........................A
..........................
...............°-------°-------°
...............B.........C..........D
...............|......................|
........°-------°..............°-----°
....... E..........F.............G.......H
...................|..............|
...........°----°----°....... L
...........I......G......K
..................|......|
..................L......M

i'm sorry about those "." but it was the only way to put the info like i want, i don't use forums to often :)
Note that the G it's in two levels (even it could be in a lot of levels) so first i have to get the informacion from a structural database (wich has
PARENT_CODE,CHILD_CODE,QTYREQ

finally, with a lot of recursivity i get that informacion in an array, like this

ARRAY
0 1 2 (Qty)
A B 2
A C 1
B E 4
and so on.
I try to use treeview but because that some products are requiered in a couple of levels, i cant use the code of the product as a key for the treeview. Even if you find another way to represent this not using treeview it could be okay.
My email is pdguevara@hotmail.com if someone could help me with this it would be awesome. Thx and please forgive my english.

elcazador
07-18-2003, 02:25 PM
I post this msg early but i read it and i think i'm no t clear, i will put the code that i use

Dim CN As ADODB.Connection
Dim RS As ADODB.Recordset
Dim ar()
Dim br()
Dim nodos As Integer
Dim f As Integer
Dim N As Node

Private Sub Command1_Click()
cargaraiz
cargamemoria (1)
muestramatrix
End Sub

Private Sub Form_Load()
Set CN = New ADODB.Connection
CN.CursorLocation = adUseClient
CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & App.Path & "\bd1.mdb"
End Sub

Function cargamemoria(k As Integer)
On Error GoTo err

Set RS = New ADODB.Recordset
RS.Open "SELECT * From a WHERE cod1 ='" & br(k) & "'", CN, adOpenStatic, adLockOptimistic
RS.MoveFirst
While Not RS.EOF
ReDim Preserve ar(nodos + 1)
ReDim Preserve br(nodos + 1)
Set N = tv.Nodes.Add(CStr(RS.Fields(0)), 4, CStr(RS.Fields(1)), RS.Fields(1), "n1") '<-------- HERE RISE the error
ar(nodos) = RS.Fields(0)
br(nodos) = RS.Fields(1)
nodos = nodos + 1
k = k + 1
RS.MoveNext
Wend
indice = indice + 1
RS.Close
cargamemoria (k)
err:
Select Case err.Number
Case 0
Case 3021

k = k + 1
cargamemoria (k)
Case 9
nodos = nodos - 1

Exit Function
Case Else
MsgBox "ERROR " & err.Number & err.Description
End Select
End Function

Function cargaraiz()

nodos = 1
indice = 1
Set RS = New ADODB.Recordset
RS.Open "SELECT * From a WHERE cod1 ='" & Text1.Text & "'", CN, adOpenStatic, adLockOptimistic
RS.MoveFirst
Set N = tv.Nodes.Add(, , CStr(Text1.Text), Text1.Text, "n1")
While Not RS.EOF
ReDim Preserve ar(nodos)
ReDim Preserve br(nodos)
Set N = tv.Nodes.Add(Text1.Text, 4, CStr(RS.Fields(1)), RS.Fields(1), "n1")
ar(nodos) = RS.Fields(0)
br(nodos) = RS.Fields(1)
nodos = nodos + 1
RS.MoveNext
Wend
End Function

Function muestramatrix()
On Error GoTo err

For f = 0 To nodos
g.TextMatrix(f, 1) = ar(f)
g.TextMatrix(f, 2) = br(f)
Next


err:
Select Case err.Number
Case 0
Case Else
MsgBox err.Number & " " & err.Description
End Select

End Function


an error of key duplication is raise, but i actually need duplication (some codes can be duplicate it. How can i solve this? any idea, if someone need the db please send my a msg, thx i send an image to see what i need
pdguevara@hotmail.com

VBJoe
07-18-2003, 03:40 PM
You're assigning the same key to two or more node objects. Keys must be unique, so possible you could create the key by concatenating two or more database fields?

Robse
07-18-2003, 08:05 PM
I don't see how you can do a parts explosion in a treeview, because
a treeview only expands in one direction per dimension (usually down and right)???

elcazador
07-19-2003, 12:08 AM
I don't see how you can do a parts explosion in a treeview, because
a treeview only expands in one direction per dimension (usually down and right)???
Actually it works okay using recursivity, but i have the duplication problem, do you have experience in parts explosion? i that so, what would you recomend me? I'm start thinking that i will have to undust my old activeX book and create a custom one, or maybe use an mshflexgrid for the representation

elcazador
07-19-2003, 12:12 AM
You're assigning the same key to two or more node objects. Keys must be unique, so possible you could create the key by concatenating two or more database fields?

unfortunatelly y have a table call "MasteR_Stock" wich has the complete iinfo of every product and another one call Estructures wich has the Parent-child and quantity of the explosion. I know that the key must be unique, but i was wondering if there is another variable or something that i could you to make unique keys, but to represent that structure.
thx

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum