4. Basic QForms
* Introduction to QListControl
<< Calculator Example with "Design"   |   Back to Main   |   Next >>

View Source
will open in a new window
The QListControl Family of Controls
QListControl controls handle simple lists of objects which can be selected. In its most basic form, we are basically talking about HTML listboxes (e.g. <select>) with name/value pairs (e.g. <option>).

Of course, listboxes can be single- and multiple-select. But note that sometimes, you may want to display this list as a list of labeled checkboxes (which basically acts like a multiple-select listbox) or a list of labeled radio buttons (which acts like a single-select listbox). Qcodo includes the QListBox, QCheckboxList and QRadioButtonList controls which all inherit from QListControl to allow you to present the data and functionality that you need to in the most user-friendly way possible.

In this example we create a QListBox control. This single-select listbox will pull its data from the Person table in the database. Also, if you select a person, we will update the lblMessage label to show what you have selected.

If you do a View Source... in your browser to view the HTML, you'll note that the <option> values are arbitrary indexes (starting with 0). This is done intentionally. QListControl uses arbitrary listcontrol indexes to lookup the specific value that was assigned to that QListItem. It allows you to do things like put in non-string based data into the value, or even to have multiple listitems point have the same exact value.

And in fact, this is what we have done. The actual value of each QListItem is not a Person Id, but it is in fact the Person object, itself. Note that in our lstPersons_Change, we never need to re-lookup the Person via a Person::Load. We simply display the Person's name directly from the object that is returned by the SelectedValue call on our QListBox.

Currently Selected: <None>