| 1 |
lars |
1 |
<com:TContent ID="body" >
|
|
|
2 |
|
|
|
3 |
<h1 id="4801">List Controls</h1>
|
|
|
4 |
<p id="550329" class="block-content">
|
|
|
5 |
List controls covered in this section all inherit directly or indirectly from <tt>TListControl</tt>. Therefore, they share the same set of commonly used properties, including,
|
|
|
6 |
</p>
|
|
|
7 |
<ul id="u1" class="block-content">
|
|
|
8 |
<li><tt>Items</tt> - list of items in the control. The items are of type <tt>TListItem</tt>. The item list can be populated via databinding or specified in templates like the following:
|
|
|
9 |
<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code_550115">
|
|
|
10 |
<com:TListBox>
|
|
|
11 |
<com:TListItem Text="text 1" Value="value 1" />
|
|
|
12 |
<com:TListItem Text="text 2" Value="value 2" Selected="true" />
|
|
|
13 |
<com:TListItem Text="text 3" Value="value 3" />
|
|
|
14 |
</com:TListBox>
|
|
|
15 |
</com:TTextHighlighter>
|
|
|
16 |
</li>
|
|
|
17 |
<li><tt>SelectedIndex</tt> - the zero-based index of the first selected item in the item list.</li>
|
|
|
18 |
<li><tt>SelectedIndices</tt> - the indices of all selected items.</li>
|
|
|
19 |
<li><tt>SelectedItem</tt> - the first selected item in the item list.</li>
|
|
|
20 |
<li><tt>SelectedValue</tt> - the value of the first selected item in the item list.</li>
|
|
|
21 |
<li><tt>AutoPostBack</tt> - whether changing the selection of the control should trigger postback.</li>
|
|
|
22 |
<li><tt>CausesValidation</tt> - whether validation should be performed when postback is triggered by the list control.</li>
|
|
|
23 |
</ul>
|
|
|
24 |
|
|
|
25 |
<p id="550330" class="block-content">
|
|
|
26 |
Since <tt>TListControl</tt> inherits from <tt>TDataBoundControl</tt>, these list controls also share a common operation known as <tt>databinding</tt>. The <tt>Items</tt> can be populated from preexisting data specified by <tt>DataSource</tt> or <tt>DataSourceID</tt>. A function call to <tt>dataBind()</tt> will cause the data population. For list controls, data can be specified in the following two kinds of format:
|
|
|
27 |
</p>
|
|
|
28 |
<ul id="u2" class="block-content">
|
|
|
29 |
<li>one-dimensional array or objects implementing <tt>ITraversable</tt> : array keys will be used as list item values, and array values will be used as list item texts. For example
|
|
|
30 |
<com:TTextHighlighter CssClass="source block-content" id="code_550116">
|
|
|
31 |
$listbox->DataSource=array(
|
|
|
32 |
'key 1'=>'item 1',
|
|
|
33 |
'key 2'=>'item 2',
|
|
|
34 |
'key 3'=>'item 3');
|
|
|
35 |
$listbox->dataBind();
|
|
|
36 |
</com:TTextHighlighter>
|
|
|
37 |
</li>
|
|
|
38 |
<li>tabular (two-dimensional) data : each row of data populates a single list item. The list item value is specified by the data member indexed with <tt>DataValueField</tt>, and the list item text by <tt>DataTextField</tt>. For example,
|
|
|
39 |
<com:TTextHighlighter CssClass="source block-content" id="code_550117">
|
|
|
40 |
$listbox->DataTextField='name';
|
|
|
41 |
$listbox->DataValueField='id';
|
|
|
42 |
$listbox->DataSource=array(
|
|
|
43 |
array('id'=>'001','name'=>'John','age'=>31),
|
|
|
44 |
array('id'=>'002','name'=>'Mary','age'=>30),
|
|
|
45 |
array('id'=>'003','name'=>'Cary','age'=>20));
|
|
|
46 |
$listbox->dataBind();
|
|
|
47 |
</com:TTextHighlighter>
|
|
|
48 |
</li>
|
|
|
49 |
</ul>
|
|
|
50 |
|
|
|
51 |
<h2 id="4802">TListBox</h2>
|
|
|
52 |
<p id="550331" class="block-content">
|
|
|
53 |
<tt>TListBox</tt> displays a list box that allows single or multiple selection. Set the property <tt>SelectionMode</tt> as <tt>Single</tt> to make a single selection list box, and <tt>Multiple</tt> a multiple selection list box. The number of rows displayed in the box is specified via the <tt>Rows</tt> property value.
|
|
|
54 |
</p>
|
|
|
55 |
<com:RunBar PagePath="Controls.Samples.TListBox.Home" />
|
|
|
56 |
|
|
|
57 |
<h2 id="4803">TDropDownList</h2>
|
|
|
58 |
<p id="550332" class="block-content">
|
|
|
59 |
<tt>TDropDownList</tt> displays a dropdown list box that allows users to select a single option from a few prespecified ones.
|
|
|
60 |
</p>
|
|
|
61 |
<p class="block-content">
|
|
|
62 |
Since v3.1.1, <tt>TDropDownList</tt> starts to support prompt text (something like 'Please select:' as the first list item). To use this feature, set either <tt>PromptText</tt> or <tt>PromptValue</tt>, or both. If the user chooses the prompt item, the dropdown list will be unselected.
|
|
|
63 |
</p>
|
|
|
64 |
<com:RunBar PagePath="Controls.Samples.TDropDownList.Home" />
|
|
|
65 |
|
|
|
66 |
<h2 id="4804">TCheckBoxList</h2>
|
|
|
67 |
<p id="550333" class="block-content">
|
|
|
68 |
<tt>TCheckBoxList</tt> displays a list of checkboxes on a Web page. The alignment of the text besides each checkbox can be specified <tt>TextAlign</tt>. The layout of the checkboxes can be controlled by the following properties:
|
|
|
69 |
</p>
|
|
|
70 |
<ul id="u3" class="block-content">
|
|
|
71 |
<li><tt>RepeatLayout</tt> - can be either <tt>Table</tt> or <tt>Flow</tt>. A <tt>Table</tt> uses HTML table cells to organize the checkboxes, while a <tt>Flow</tt> uses HTML span tags and breaks for the organization. With <tt>Table</tt> layout, you can set <tt>CellPadding</tt> and <tt>CellSpacing</tt>.</li>
|
|
|
72 |
<li><tt>RepeatColumns</tt> - how many columns the checkboxes should be displayed in.</li>
|
|
|
73 |
<li><tt>RepeatDirection</tt> - how to traverse the checkboxes, in a horizontal way or a vertical way (because the checkboxes are displayed in a matrix-like layout).</li>
|
|
|
74 |
</ul>
|
|
|
75 |
|
|
|
76 |
<com:RunBar PagePath="Controls.Samples.TCheckBoxList.Home" />
|
|
|
77 |
|
|
|
78 |
<h2 id="4805">TRadioButtonList</h2>
|
|
|
79 |
<p id="550334" class="block-content">
|
|
|
80 |
<tt>TRadioButtonList</tt> is similar to <tt>TCheckBoxList</tt> in every aspect except that each <tt>TRadioButtonList</tt> displays a group of radiobuttons. Only one of the radiobuttions can be selected (<tt>TCheckBoxList</tt> allows multiple selections.)
|
|
|
81 |
</p>
|
|
|
82 |
<com:RunBar PagePath="Controls.Samples.TRadioButtonList.Home" />
|
|
|
83 |
|
|
|
84 |
<h2 id="4806">TBulletedList</h2>
|
|
|
85 |
<p id="550335" class="block-content">
|
|
|
86 |
<tt>TBulletedList</tt> displays items in a bullet format on a Web page. The style of the bullets can be specified by <tt>BulletStyle</tt>. When the style is <tt>CustomImage</tt>, the bullets are displayed as images, which is specified by <tt>BulletImageUrl</tt>.
|
|
|
87 |
</p>
|
|
|
88 |
<p id="550336" class="block-content">
|
|
|
89 |
<tt>TBulletedList</tt> displays the item texts in three different modes,
|
|
|
90 |
</p>
|
|
|
91 |
<ul id="u4" class="block-content">
|
|
|
92 |
<li><tt>Text</tt> - the item texts are displayed as static texts;</li>
|
|
|
93 |
<li><tt>HyperLink</tt> - each item is displayed as a hyperlink whose URL is given by the item value, and <tt>Target</tt> property can be used to specify the target browser window;</li>
|
|
|
94 |
<li><tt>LinkButton</tt> - each item is displayed as a link button which posts back to the page if a user clicks on that, and the event <tt>OnClick</tt> will be raised under such a circumstance.</li>
|
|
|
95 |
</ul>
|
|
|
96 |
|
|
|
97 |
<com:RunBar PagePath="Controls.Samples.TBulletedList.Home" />
|
|
|
98 |
|
|
|
99 |
<div class="last-modified">$Id: List.page 2256 2007-09-28 02:04:47Z xue $</div></com:TContent>
|