More Listbox Features

The listbox element was described in an "listsearlier section. It has a number of additional features that are described below.

Multi-Column List Boxes

The ref_listboxlistbox element is used to create a list of items from which the user can select one or more items from. It is internally created in using a grid. It simply uses a set of custom tags and adds code to handle selection automatically. You might use it when you need a grid with selectable rows.

Because it is a grid, it supports multiple columns. Each cell may have arbitrary content within it, although usually only text is used. In a listbox, the content always goes in the rows, unlike a grid where the content may be placed either in the rows or the columns. The syntax is similar but different tags are used. The following table lists the equivalent tags in a listbox:

DescriptionTag in a GridTag in a Listbox
Outer elementgridlistbox
A group of columnscolumnslistcols
A single columncolumnlistcol
A group of rowsrows( no equivalent )
A single rowrowlistitem
A single cell( no equivalent )listcell

List boxes have no equivalent of the grid's ref_rowsrows element. Actually, there is an equivalent, but it is created automatically and placed in the list box for you. It is also hidden so you don't even need to know it is there.

The ref_listcelllistcell element may be used for each cell in the grid. To specify the text content of a cell, place a label attribute on a ref_listcelllistcell. For the simple case where there is only one column, you may also place the label attributes directly on the ref_listitemlistitem elements and leave the ref_listcelllistcell elements out entirely.

When the user selects an item, the entire row is selected. You cannot have a single cell selected.

The following example is of a listbox with two columns and three rows:

Example 6.2.1: /ex_6_2_1.xul.txt'>Source "examples/ex_6_2_1.xulONCLICKwindow.open('examples/ex_6_2_1.xul','xulex','chrome,resizable'); return false;View
<listbox <listcols <listcol flex1/ <listcol flex2/ </listcols <listitem <listcell labelGeorge/ <listcell labelHouse Painter/ </listitem <listitem <listcell labelMary Ellen/ <listcell labelCandle Maker/ </listitem <listitem <listcell labelRoger/ <listcell labelSwashbuckler/ </listitem </listbox

This list box has two columns, the second one being twice as flexible as the first one. If you shrink the size horizontally, the labels on the cells will crop themselves automatically. As with other elements, you can use the crop attribute on the cells or items to control the cropping.

Header Rows

List boxes also allow a special header row to be used. This is much like a regular row except that it is displayed differently. You would use this to create column headers. Two new elements are used.

/morelists1.jpgALIGN=RIGHT ALT= =216 =103> The ref_listheadlisthead element is used for the header rows, just as the ref_listitemlistitem element is used for regular rows. The header row is not a normal row however, so using a script to get the first row in the list box will skip the header row.

The ref_listheaderlistheader element is used for each cell in the header row. Use the label to set the label for the header cell.

Here is the earlier example with a header row:

Example 6.2.2: /ex_6_2_2.xul.txt'>Source "examples/ex_6_2_2.xulONCLICKwindow.open('examples/ex_6_2_2.xul','xulex','chrome,resizable'); return false;View
<listbox <listhead <listheader labelName/ <listheader labelOccupation/ </listhead <listcols <listcol flex1/ <listcol flex2/ </listcols <listitem <listcell labelGeorge/ <listcell labelHouse Painter/ </listitem <listitem <listcell labelMary Ellen/ <listcell labelCandle Maker/ </listitem <listitem <listcell labelRoger/ <listcell labelSwashbuckler/ </listitem </listbox

"trees(Next) Next, we'll look at how to create trees.

Examples: /ex_6_2_1.xul.txt'>6.2.1 /ex_6_2_2.xul.txt'>6.2.2

"comments/?for=tutorials%2Fxultu%2Fmorelists /notes-add alt= 1313alignmiddleborder0/> "comments/?for=tutorials%2Fxultu%2FmorelistsclasssmallAdd a note User Contributed Notes
No comments available
"comments/?for=tutorials%2Fxultu%2Fmorelists /notes-add alt= 1313alignmiddleborder0/> "comments/?for=tutorials%2Fxultu%2FmorelistsclasssmallAdd a note

Bhopal news
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

freelance web designer india ecommerce web developer | Ecommerce web design, software developer india | Web hosting India Windows hosting | India web hosting Windows hosting India | India software developer | web designer india