A ListView is a control that displays data arranged as a rectangular grid of rows and columns. Each row is a selectable item. Each element in the row is called a cell.
NULL
and item as FALSE
or blank.NULL
and item as TRUE
.The function used to create rows and cells is wb_create_items(). This function can create one or more rows at once by passing an array of arrays as the items parameter. Each element of the second-level array is the value of a cell to be inserted. The function returns the index of the lastly inserted row.
Function wb_set_text() can be used to change the text of a single cell or row. Use the table below:
text |
item |
subitem |
What it does |
---|---|---|---|
string |
integer |
integer |
Sets the text of the cell indexed by item (the row) and subitem (the column). |
array of strings |
integer |
blank |
Sets the text of all cells in the row indexed by item. A NULL element will skip a cell. |
|
|
blank |
Clears all column titles |
|
|
blank |
Clears all cells |
To retrieve the text of a cell, row or the whole ListView, use wb_get_text(). Use the following table:
item |
subitem |
What it retrieves |
---|---|---|
integer |
integer |
The text of the cell indexed by item (the row) and subitem (the column). |
integer |
blank |
An array containing the text of all cells in the row indexed by item. |
blank |
blank |
A two-dimensional array containing the text of all cells of the control. |
You may assign an image to a treeview cell using function wb_set_item_image(). The parameter item specifies the row index and subitem is the column index.
The code below shows how to create a list view and add some data to it.
// Create a ListView $list = wb_create_control($mainwin, ListView, "", 5, 30, 540, 200, ID_ITEMLIST, WBC_VISIBLE | WBC_ENABLED | WBC_SORT | WBC_LINES | WBC_CHECKBOXES); // Set the column titles wb_set_text($list, array( array("File", 100), array(null, 80), array("Name", 140), array("Update", 200), )); // Create rows and columns wb_create_items($list, array( array("1,000", "Bob", "John", "Peter"), array(0, "Sue", "Paul", "Mary"), array("200", null, 300/2, pi()), )); // Set listview images wb_set_image($list, PATH_RES . "toolbar.bmp", GREEN, 32); wb_set_item_image($list, 5, 0, 1); wb_set_item_image($list, 2, 2, 3); |