06-15-2011, 03:58 PM,
(This post was last modified: 06-16-2011, 10:41 AM by kino.)
|
|||||
|
|||||
User Interface Basics4:Populating Control List Data
Allowing a user to select one or more items from a list is a common Web design pattern. A ListBox permits the programmer to display a number of items, allow the user to make a selection, and then proceed accordingly. ListBoxes are ideal controls for presenting a list of choices to the user---whether a few items or a large number.
In Curl, a ListBox is used to select multiple items. Each selection can be displayed as either text or graphics. The choices are displayed in single vertical column. Zero, one, or more of the choices can be selected by the user. Code: {curl 6.0, 7.0 applet} Notice that scrollbars will automatically appear if the ListBox height is greater than the specified height. If the height is not specified, the ListBox will display all selections. Also, the style of the displayed items has been set to checkbutton which provides a small box to show what is selected. When an item is selected, a "check" graphic will appear in the box. The style can also be set to standard, in which it looks and behaves like a traditional list control. If the requirement is that a maximum of one item can be selected from the list, you can set ListBox.selection-policy to "single" instead of the default policy of "multiple". You may also want to consider using ComboBox, DropdownList or RadioButton classes. Creating List Items from Accessed Data It is common that the selectable items are dynamically retrieved at runtime from an external source such as a database. We can query the data and temporarily store it using an array, hashtable, recordset, or other method of storage. The append or insert methods are used to add new items to the ListBox. Items appended to a ListBox appear in the order in which they were added. For our example, we will store our list data in an array and then append each item in the array to the ListBox. Code: {curl 6.0, 7.0 applet} Code: {curl 6.0, 7.0 applet} Getting Selected Values Once the user has made their selections, you will need to gather the information for display or further processing. The user selected items in a ListBox are stored as an array in the value property. We can loop through the items of the array to obtain the selected values. In our example below, the selected values are gathered and displayed in a VBox. Code: {curl 6.0, 7.0 applet} For more information regarding List Controls, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Graphical User Interface > List Controls The next example takes input from a TextField and appends those values to a ListBox. The ListBox displays the current entries. Code: {curl 6.0, 7.0 applet} Notice that unset-value is used to clear the input value in the TextField when the user presses enter. For more information regarding Text Controls, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Graphical User Interface > Text Controls |
|||||
« Next Oldest | Next Newest »
|
Possibly Related Threads... | |||||
Thread | Author | Replies | Views | Last Post | |
XML1:XML Data | kino | 3 | 9,750 |
10-21-2013, 12:48 PM Last Post: Leta56 |
|
Persistent Data1:Client-side Persistent Data | kino | 0 | 6,565 |
06-15-2011, 05:24 PM Last Post: kino |
|
Files over HTTP4:Viewing RecordSet Data | kino | 0 | 4,859 |
06-15-2011, 04:46 PM Last Post: kino |
|
Files over HTTP3:Connected Data | kino | 0 | 7,072 |
06-15-2011, 04:42 PM Last Post: kino |
|
Files over HTTP2:Organizing Data using RecordSets | kino | 0 | 5,492 |
06-15-2011, 04:35 PM Last Post: kino |
|
User Interface Basics7:Stretching Graphical Objects | kino | 0 | 4,781 |
06-15-2011, 04:12 PM Last Post: kino |
|
User Interface Basics6:Object Layout | kino | 0 | 4,507 |
06-15-2011, 04:08 PM Last Post: kino |
|
User Interface Basics5:Swapping UI Content | kino | 0 | 3,500 |
06-15-2011, 04:03 PM Last Post: kino |
|
User Interface Basics3:Creating Dialogs | kino | 0 | 3,360 |
06-15-2011, 03:55 PM Last Post: kino |
|
User Interface Basics2:Adding Pop-ups | kino | 0 | 3,718 |
06-15-2011, 03:52 PM Last Post: kino |
Users browsing this thread:
1 Guest(s)
1 Guest(s)