Tree Control Syntax

Syntax

[[ %Directives% ][. Width [, Height ]] Node ^< Choice_Array [ ! Events ] ]

Arguments

%Directives%

Refer to Xdialog Language Directives and Operators.

Width

Numeric. The width of the control.

Height

Numeric. The height of the control.

Node

Character. The variable that receives the user's selection.

^<

Character. Required as shown.

Choice_Array

Character. An array of character values.

Events

Character. Performance considerations recommend dynamic calculation of event names into a CR-LF delimited string.

Description

The formatting string %S=BLR% is used to specify that a tree control should be displayed with the familiar boxes and lines. To set the default choice for the tree control, set the value of Node before running UI_DLG_BOX(). In the following example, setting node to "b.1.A" would cause the tree to open so that "b.1.A" was visible and highlighted.

dim data[10] as C
data[1] = "a.1.A"
data[2] = "a.1.B"
data[3] = "a.2.A"
data[4] = "a.2.B"
data[5] = "b.1.A"
data[6] = "b.1.B"
data[7] = "b.2.A"
data[8] = "b.2.B"
result=ui_dlg_box("Simple Tree",<<%dlg%
{ysize=2}
[%S=BLR%.32,10node^<data] |
 <OK>
%dlg% )
images/XD_Tree Control_1.gif

The following diagram shows the tree control and its return value. Picture

dim data[10] as C
data[1] = "a.1.A"
data[2] = "a.1.B"
data[3] = "a.2.A"
data[4] = "a.2.B"
data[5] = "b.1.A"
data[6] = "b.1.B"
data[7] = "b.2.A"
data[8] = "b.2.B"
result=ui_dlg_box("Simple Tree",<<%dlg%
{ysize=2}
[%S=BLR%.32,10node^<data] |
<OK>;
[.32node]
%dlg% )
images/XD_Tree Control_2.gif

Using the Macro Expansion Symbol

The tree control may optionally use the macro expansion symbol, as illustrated below. I=@images is a reference to the images variable in the example below.

images = <<%dlg% 
a5_ball_blue 
a5_ball_green 
a5_ball_red 
a5_ball_yellow 
a5_orange_question_small 
%dlg%
  
list = <<%dlg% 
3+1Category1.5item1 
3+1Category1.5item2 
3+2Category2.5item3 
3+2Category2.5item4 
3+4Category3.5item5 
3+4Category3.5item6 
%dlg%
  
ui_dlg_box("Tree Control Images",<<%dlg% 
[%S=BLR;I=@images%.30,15item_selected^<list]; 
%dlg%)
images/XD_Tree_Control_Images.gif

Note however, that this example could also have been done without a macro expansion as follows:

images = <<%dlg% 
a5_ball_blue 
a5_ball_green 
a5_ball_red 
a5_ball_yellow 
a5_orange_question_small 
%dlg%
  
list = <<%dlg% 
3+1Category1.5item1 
3+1Category1.5item2 
3+2Category2.5item3 
3+2Category2.5item4 
3+4Category3.5item5 
3+4Category3.5item6 
%dlg% 
dlg_body = "[%S=BLR;I="+images+"%.30,15item_selected^<list];" 
ui_dlg_box("Tree Control Images",dlg_body)

See Also