Class XbpTreeViewItem() Foundation

Class function of the XbpTreeViewItem class.


Instances of the XbpTreeViewItem class manage a single item within a tree structure (tree view). These objects are highly specialized and can only be used in conjunction with an XbpTreeView object. An XbpTreeViewItem object provides data for displaying an item while the XbpTreeView object manages the screen and lets the user navigate through the tree view.

When an item is displayed, text can be combined with graphic information such as bitmap or icon. If an image is displayed, it must be supplied as a resource linked to an executable file (EXE or DLL). The graphic information is used to visualize three possible states of an XbpTreeViewItem object: normal, marked and expanded. The "expanded" state is given when sub-items of an XbpTreeViewItem object are visible.

Within a tree view, an XbpTreeViewItem object is used for both "node" and "leaf". A node branches to a sub-level in the tree which means that it contains additional XbpTreeViewItem objects which display data of the sub-level.

The creation of an XbpTreeViewItem object can be done using the usual pattern for Xbase Parts: :new(), configuration and :create(). However, the method :addItem() provides a simplified way to create such objects. It accepts as parameters the configuration data for a new XbpTreeViewItem object and executes the methods :new() and :create() implicitly. Therefore, an entire tree view can be build solely by using the :addItem() method.

Class methods
Creates an instance of the XbpTreeViewItem class.
Text to be displayed as caption.
Name of the DLL file containing icons or bitmaps
Resource ID, XbpBitmap or XbpIcon object of the bitmap or icon which indicates the expanded state.
Resource ID, XbpBitmap or XbpIcon object of the bitmap or icon which indicates the normal state.
Resource ID, XbpBitmap or XbpIcon object of the bitmap or icon which indicates the marked state.
Life cycle
Requests system resources for the XbpTreeViewItem object.
Releases the system resources of the XbpTreeViewItem object.
Display methods
Displays or hides sub-items of an XbpTreeViewItem object.
Determines whether or not sub-items are visible.
Specifies a new caption.
Specifies a new image representing the expanded state.
Specifies a new image for the tree view item.
Specifies a new image representing the marked state.
Returns the value associated with an XbpTreeViewItem object
Associates a value with the XbpTreeViewItem object.
Item Management
Adds a new item (leaf) to a tree node.
Deletes an item from a sub-level.
Returns all items of a sub-level
Returns the item of the next-higher level (a node item).
Inserts a new item (leaf) to the next sub-level.
Building a tree view

// The example demonstrates the basic process for 
// building a tree view. 

#include "" 

   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL oTree, oItem1, oItem2 

   oTree := XbpTreeView():new( ,, {0,0}, {640,400} ) 

   oTree:hasLines   := .T. 
   oTree:hasButtons := .T. 

   oItem1 := oTree:rootItem:addItem( "First level A" ) 
   oTree:rootItem:addItem( "First level B" ) 

   oItem2 := oItem1:addItem( "Second level A" ) 

   oItem1:addItem( "Second level B" ) 

   oItem2:addItem( "Third level A" ) 
   oItem2:addItem( "Third level B" ) 
   oItem2:addItem( "Third level C" ) 

   DO WHILE nEvent <> xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:handleEvent( nEvent, mp1, mp2 ) 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.