Rapid-Q Documentation by William Yu (c)1999 Appendix A: QTREEVIEW

QTREEVIEW Component

QTreeView displays a hierarchical list of items. Items are ordered by their index.

QTreeView Internal Types
   TYPE TreeNodeType           '' ie. TreeView.Item(0).Text
     Text AS STRING
     ImageIndex AS INTEGER
     StateIndex AS INTEGER
     SelectedIndex AS INTEGER
     Count AS INTEGER          '' Read only
     Level AS INTEGER          '' Read only
     IsVisible AS INTEGER      '' Read only
     Handle AS INTEGER         '' Read only
     HasChildren AS INTEGER
     Selected AS INTEGER
   END TYPE
QTreeView Properties
FieldTypeR/WDefault
AlignINTEGERRWalNone
BorderStyleINTEGERRWbsSingle
ColorINTEGERRW
CursorINTEGERRWcrDefault
EnabledINTEGERRWTrue
FontQFONTW
HandleINTEGERRW
HeightINTEGERRW
HideSelectionINTEGERRWFalse
HintSTRINGRW
ImagesQIMAGELISTW
IndentINTEGERRW19
ItemARRAY of TreeNodeTypeRW
ItemCountINTEGERRW
ItemIndexINTEGERRW
LeftINTEGERRW0
ParentQFORM/QPANEL/QTABCONTROLW
PopupMenuQPOPUPMENUW
ReadOnlyINTEGERRWFalse
ShowButtonsINTEGERRWTrue
ShowHintINTEGERRWFalse
ShowLinesINTEGERRWTrue
ShowRootINTEGERRWTrue
SortTypeINTEGERRWstText
StateImagesQIMAGELISTW
TabOrderINTEGERRW
TagINTEGERRW
TopINTEGERRW0
TopIndexINTEGERRW
WidthINTEGERRW
VisibleINTEGERRWTrue

QTreeView Methods
MethodTypeDescriptionParams
AddItemsSUBIAdd items to treeviewSTRING, Infinite
AddChildItemsSUB (Index%, S1$, S2$, ...)Add child item at Index%Minimum 2
ClearSUBClear all items in treeview0
CollapseSUB (Index%, Recurse%)Collapses node2
DelItemsSUBIDelete items from treeviewINTEGER, Infinite
ExpandSUB (Index%, Recurse%)Expand node, revealing its childs2
FullCollapseSUBCollapses all nodes0
FullExpandSUBExpands all nodes0
GetItemAtFUNCTION (X%, Y%) AS LONGGet the index node at X,Y2
InsertItemSUB (Index%, String$)Insert item at Index%2
LoadFromFileSUB (Filename AS STRING)Load items from file1
SaveToFileSUB (Filename AS STRING)Save items to file1
SortSUBSort all items from A-Z0

QTreeView Events
EventTypeOccurs when...Params
OnClickVOIDTreeView was clicked on0
OnChangeSUB (Index%)Selection (not modification) has changed from one item to another1
OnChangingSUB (Index%, AllowChange%)Selection is about to be changed2
OnCollapseSUB (Index%)Just after a node has been collapsed1
OnCollapsingSUB (Index%, AllowCollapse%)A node is about to be collapsed2
OnDblClickVOIDTreeView was double clicked on0
OnDeletionSUB (Index%)A node in the tree is deleted1
OnEditedSUB (Index%, BYREF S$)After the user edits a text of a node2
OnEditingSUB (Index%, AllowEdit%)The user starts to edit the text2
OnExpandSUB (Index%)After a node is expanded1
OnExpandingSUB (Index%, AllowExpansion%)A node is about to be expanded2
OnGetImageIndexSUB (Index%)The treeview looks up the ImageIndex of a node1
OnGetSelectedIndexSUB (Index%)The treeview looks up the SelectedIndex of a node1
OnKeyDownSUB (Key AS Word, Shift AS INTEGER)Key held down2
OnKeyPressSUB (Key AS BYTE)User presses a key1
OnKeyUpSUB (Key AS Word, Shift AS INTEGER)User releases a key2
OnMouseDownSUB (Button%, X%, Y%, Shift%)Mouse button held down4
OnMouseMoveSUB (X%, Y%, Shift%)Mouse moves3
OnMouseUpSUB (Button%, X%, Y%, Shift%)Mouse button is released4


QTreeView Examples
'' Tree view example, hot tracking through items

SUB TreeViewChange (Node AS INTEGER, AllowChange AS INTEGER, Sender AS QTREEVIEW)
    IF Node = 8 THEN AllowChange = 0
END SUB

SUB TreeViewMouseMove (X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QTREEVIEW)
    I = Sender.GetItemAt(X,Y)
    IF I >= 0 THEN Sender.ItemIndex = I
END SUB

CREATE Form AS QFORM
    Center
    CREATE TreeView AS QTREEVIEW
        Align = 5
        AddItems "1","2","3"
        AddChildItems 0, "Sub 1", "Sub 2", "Sub 3"
        AddChildItems 4, "Sub 1", "Sub 2", "Sub 3"
        FullExpand
        OnChanging = TreeViewChange
        OnMouseMove = TreeViewMouseMove
    END CREATE
END CREATE


'-- No real purpose, just change all items
FOR I = 0 TO TreeView.ItemCount-1
    TreeView.Item(I).Text = STR$(I)
NEXT

Form.ShowModal

Prev Component Contents Next Component
Hosted by uCoz
D>
Hosted by uCoz