Tree View Item - ParentItem Property

ParentItem is the next item up

Member of Tree View Item (PRIM_TVIT)

Data Type - PRIM_TVIT - Entry in a tree view

Details

The ParentItem property is the item in the tree containing the item.
 
Items at the root of the tree will have a ParentItem of Null.
 
Trees with a ViewStyle of Levelled will automatically assign the ParentItem based on the data when the tree is constructed.
 
Those with a ViewStyle of Unlevelled require that the ParentItem be assigned programmatically.

Example

This example is a simple tree that adds 5 items. Whenever an item is expanded, the Tree adds 5 child items to the expanding item
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(480) Clientheight(398) Left(259) Top(261) Height(437) Width(496) Layoutmanager(#TableLayout1)
 
   Define_Com Class(#PRIM_TBLO) Name(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Item) Name(#TreeView1Item1) Column(#Column1) Manage(#Tree) Parent(#TableLayout1) Row(#Row1)
 
   Define_Com Class(#PRIM_TRVW) Name(#Tree) Columnbuttonheight(19) Componentversion(2) Displayposition(1) Height(398) Keyboardpositioning(SortColumn) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Width(480) Viewstyle(UnLevelled)
   Define_Com Class(#PRIM_TVCL) Name(#TreeViewColumn1) Displayposition(1) Level(1) Parent(#Tree) Source(#xDemoNumber) Width(43)
 
   Evtroutine Handling(#Com_owner.CreateInstance)
 
      #Com_Self.Add5Items
 
   Endroutine
 
   Mthroutine Name(Add5Items)
   Define_Map For(*input) Class(#Prim_tvit) Name(#ParentItem) Mandatory(*Null) Pass(*By_reference)
 
      Begin_Loop Using(#xDemoNumber) To(5)
 
         Add_Entry To_List(#Tree)
 
         #Tree.CurrentItem.ParentItem <= #ParentItem
         #Tree.CurrentItem.HasChildren := Unknown
 
      End_Loop
 
   Endroutine
 
   Evtroutine Handling(#Tree.ItemExpanding)
 
      If (#Tree.CurrentItem.HasChildren <> Yes)
         #Com_Self.Add5Items( #Tree.currentitem )
      Endif
 
   Endroutine
 
End_Com

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2