I finally figured that out. I was having a hard time seeing what the parameters passed to .add were (where is the documentation for a treeview control?) and in the end I changed my parent table structure to have it include some additional 'pointers' to each record's parent record in the same table. It is sort of unusual because in this case, the parent table can actually have children 'inside' the same table. Those children can have children, etc. Then each record in the parent table, regardless of if it is a parent, grandparent, child, etc has multiple child records (details) in a separate child table. I played around with creating different tables for each level but it turned out to be unecessary as long as I can point to the correct record in the parent table which I can. I really only needed to know who is the parent of whom in the parent table for the purpose of populating the treeview. The grid shows the details of each node and that link is based on the parent key and child foreign key. It's been a fun project! :o) I worked with a customized treeview from a class in the past, but not the standard treeview so it threw me off from the start...
>Its good to see you tricking the treeview:-). The is a download #
16575 that has sourced some of the suff you are working through. If you can use actual key field data for your node keys, it seems to make it easier to point back and forth. For example, you select a grid row, use the the key fields in that row to "select" a tree node. Or - the reverse - you select a tree node, use the nodes key value to point to a row in the grid.
>
>An issue with node's text is that two nodes may have the same string in their text - but - only one [uniquie] string can be applied as a node's key.
>
>
>>That was it, thanks!
>>Tracy
>>
>>>>If my treeview's node.text = "1MHG" and the node.key= < some specific key > , how do I programmatically jump to that node in the treeview, select it, and expand it?
>>>
>>>* To Jump to and expand
>>>if type('oTV.Nodes(cSomeSpecificKey).key')=="C"
>>> * The node with cSomeSpecificKey exists in oTV
>>> if oTV.Nodes(cSomeSpecificKey).text="1MHG"
>>> * cSomeSpecificKey has the required text.
>>> oTV.Nodes(cSomeSpecificKey).Selected=.t.
>>> *!*oTV.SelectedItem.Expanded=.t.
>>> else
>>> endif
>>>endif
>>>
>>>
>>>>
>>>>Here is where I populate the treeview. Ideally, I would go ahead and expand the 1MHG node when it is created below:
>>>>
>>>>
>>>>THIS.oletreeview.nodes.clear()
>>>>WITH THIS.oletreeview.nodes
>>>> .ADD(,tvwFirst,'File_Name'+'_'+'0000',thisform.Al3_file)
>>>> .ADD('File_Name'+'_'+'0000',tvwChild,'Message1'+'_'+'0000','Message(1)')
>>>> SELE Al3Parnt
>>>> SET ORDER TO 0
>>>> SCAN
>>>> DO CASE
>>>> CASE Al3Parnt.cself = "1MHG"
>>>> .ADD('Message1'+'_'+'0000',tvwChild,al3parnt.ckey,TRIM(al3Parnt.cSelf))
>>>> *Now expand the 1MHG Node somehow
>>>> CASE Al3Parnt.cself = "2TRG"
>>>> .ADD('Message1'+'_'+'0000',tvwChild,'2TRG'+'_'+SEQ,'Transaction('+ALLTRIM(STR(al3Parnt.ntran))+')')
>>>> CASE Al3Parnt.cself = "3MTG"
>>>> .ADD('Message1'+'_'+'0000',tvwChild,al3parnt.ckey,LEFT(TRIM(al3Parnt.cSelf),4))
>>>> CASE Al3Parnt.cPARENT = "A0"
>>>> .ADD('2TRG'+'_'+SEQ,tvwChild,al3parnt.ckey,TRIM(Al3Parnt.label))
>>>> OTHERWISE
>>>> .ADD(Al3Parnt.cp_id, tvwChild, ;
>>>> al3Parnt.ckey,TRIM(Al3Parnt.label))
>>>> ENDCASE
>>>> ENDSCAN
>>>>ENDWITH
>>>>
>>>>
>>>>
>>>>TIA,
>>>>Tracy
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"