A further extension to the Phrases example is the use of the CheckListBox component, a component originally introduced by Borland in Delphi 3. This is basically a list box with a custom output (or an owner-draw list box, to use the proper technical term). Each item of the list is preceded by a check box. A user can select a single item of the list, but can also click on the check boxes to toggle their status.
If the component has the AllowGrayed property set to True, then each check box can be non-selected, grayed, or selected. Clicking on the check box alternates these three possible conditions. To check the current status of each item you can use the Checked and the State property. Both are array properties. The first, Checked, is a Boolean property you should use when AllowGrayed is set to False. The second, State, is a property of the TCheckBoxState data type:
TCheckBoxState = (cbUnchecked, cbChecked, cbGrayed) This property should be used when AllowGrayed is set to True, to distinguish among the three different states of each item. Apart from these properties, the specific user interface, and the new OnClickCheck event, this component behaves as a ListBox.
As I mentioned at the beginning of this section, to show you an example of the use of this component I've further updated the Phrases3 example, building the Phrases4 version. I've basically replaced the first multiple selection list box with the new CheckListBox component, set its Sorted property to True, and copied the Items. Then I've updated the code, replacing the ListBoxl object with the CheckListBoxl object, and replacing the Selected property of the first with the Checked property of the second in the ChangeText method. Here is an excerpt of the new version of this method:
| for ListItem := 0 to CheckListBoxl.Items.Count - l do
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.