Programmer Guide/Shell Items/Dialog/Dialog Controls/Listview
SET dialog index LISTVIEW row col text var1 w h var2 [fg bg font] /T [ /A|L|R ] [ /E ] [ /F[=PCAFS] ] [ /R=n ]
The LISTVIEW
control is an enhanced variant of LISTBOX
(q.v.). It displays each table field in a separate column and has a built-in function for sorting tables. The data exchange is implemented in the same way as for the LISTBOX
control. Rows which are tagged in the table are used to initialize listview row selection, after which the table parameter's tags reflect the listview's selection.
var1 | The name of the index (single selection) or counter variable (extended selection). |
var2 | The name of the extended table item containing list items |
/T
|
This is a mandatory and therefore not an option! |
/X
|
X stands for eXtended selection. If specified, more than one entry can be selected at one time. See LISTBOX for details.
|
/Header
|
If specified, column headers are displayed. Note that if you do not configure the var2 table, then the field ids are used for the header text. |
/Sort
|
If specified, column headers are displayed and can be used to sort the entries. |
/Grid
|
If specified, grid lines are displayed between rows and columns |
/J
|
If specified, columns are automatically sized to fit their widest entry. |
/Centervertically
|
If specified, the selected entry is automatically centered vertically. |
/E
|
If this flag is not set on creation, the ListView will not be editable regardless of the connected tables display attributes. See the example script editabletable.sts for a complete example.
|
/F[=PCAFS]
|
If no modifier is specified, all keys are forwarded.
Any combination of the modifiers is allowed. The modifiers have the following meaning:
|
/R= n
|
If specified, n determines the maximum number of lines of text which can be displayed in the listview. |
See Common arguments for a description of the parameters not described here. The ListView sends messages when it's data has changed.
Use the SET dialogItem listviewIndex STARTEDIT
command to programmatically start editing a cell in a LISTVIEW
.
Note that a lot of the listview's configuration is read from the var2 table. You can configure the table using the SET TABLE CONFIG
command.
[macro TestListView] // create table data #t := new table * /E * string:s1 string:s2 if '$#t[?]' != 'table' em -1 ; failed to create the table $#t config s1 1 1 1 %s 0 'heading1' * 0 1 $#t config s2 1 1 1 %s 0 * 0 1 // no heading specified. field name will be used for #i := 0 to $#i < 100 step #i := int $#i + 1 $#t * s1 's1str$#i' s2 's2str$#i' end // create the dialog item #dlg := $(createmenu frame * ListView Text Dialog) #map := CDlgMap $#dlg $#dlg $($#map ci ok) button 0 0 '&OK' * 10 1 $#dlg $($#map ci cancel) button 0 10 '&Cancel' * 10 1 $#dlg $($#map ci) listview 1 0 #i 20 10 $#t /X /J /Header /Sort /Center // update dialog controls $#dlg * /Write // begin the modal mode domodaldialog begin $#dlg $#dlg 1 focus do forever // enter message loop // update the control $#dlg * /Write // get next dialog message domodaldialog loop $#dlg $($#map ci ok) $($#map ci cancel) // id and parameter only are returned readvar result #id #par // update the variables $#dlg * /Read // process messages if '$#id' == COMMAND then #ctl := set $($#map cn $#par) if '$#ctl' == 'ok' || '$#ctl' == 'cancel'then break // leave message loop end end end domodaldialog end // end modal mode // clean up delete $#t $#dlg $#map exit
A further example can be found in the example script file editabletable.sts
.