ComboBox Class
|
|
Create a combo box, which is used when you need to provide the user with both a list of choices and an edit control (to optionally allow them to type in their own choice).
Inheritance Hierarchy
Namespace:
VO
Assembly:
VOGUIClasses (in VOGUIClasses.dll) Version: 2.24 GA
SyntaxThe ComboBox type exposes the following members.
Constructors
Properties|
| Name | Description |
|---|
 | CurrentText |
ComboBox:CurrentText contains the text currently appearing in the edit box area of the combo box. The CurrentText assign also changes TextValue and Value. If the assigned CurrentText does not match one of the displayed items, then CurrentItemNo is set to 0. If the assigned value represents a change, then ValueChanged will be set to TRUE.
(Overrides CurrentText.) |
 | EditHandle |
The handle to the edit portion of a ComboBox control.
|
 | EditHeight |
Integer value specifying the height of the embedded edit control.
|
Top
Methods|
| Name | Description |
|---|
 | SetCueBanner |
Add a cue banner to the Edit portion of the ComboBox control.
|
Top
Remarks
A combo box (also known as a combination box) is a control that combines the abilities of an edit control and a list box. There are three types of combo boxes—simple, drop-down, and drop-down list.
A combo box displays a list of items or choices to the user, as well as allowing text to be entered directly into an edit area. The combo box methods will allow you to add, arrange, remove, and interrogate the list of items.
When one of the items is selected, ComboBox:CurrentItem, ComboBox:CurrentItemNo, ComboBox:TextValue, and ComboBox:Value are updated. Either a one-dimensional or two-dimensional array is specified in the FillUsing() method, with a row for each of the items available for selection. With a two-dimensional array, the first element is called the display value, and the second element is called the return value. When an item is selected, the ComboBox:TextValue contains the first element (the display value), and ComboBox:Value contains the second element (the return value). When text is directly entered, ComboBox:CurrentItemNo is set to 0 and the new text is stored in ComboBox:TextValue and ComboBox:Value.
A combo box may be bound to a field (character, date, logical, numeric, or memo) in a server. The field's data value is stored in ComboBox:Value. The combo box compares the data value to the second element values specified in the FillUsing() array, and if a match is found, the first element (the display value) is stored in ComboBox:TextValue. In a "no-match" situation, the combo box shows no item selected, ComboBox:CurrentItem is NULL_STRING, ComboBox:CurrentItemNo is set to 0, and ComboBox:TextValue and ComboBox:Value reflect the field contents. If an item is selected, ComboBox:CurrentItemNo is set to a number between 1 and ComboBox:ItemCount, and the corresponding second element is stored as ComboBox:Value and as the field's data value. If text is directly entered, it will also be stored as the field's data value.
Use the Window:ListBoxSelect() event handler to respond to selections, and the Window:ListBoxClick() event handler to respond to choices.
A combo box is primarily a selection device, so there is no special support for the functionality available in the Edit class. However, the contents of the edit component can be changed or obtained using the inherited CurrentText access/assign methods.
The combo box also generates EditFocusChangeEvents when its edit control loses or receives the focus.
Examples
This example creates a combo box and fills it with a list of animals:
1CLASS MyWindow INHERIT TopAppWindow
2HIDDEN oCB AS OBJECT
3METHOD Init() CLASS MyWindow
4SUPER:Init()
5oCB := ComboBox{SELF,42,Point{10,10},;
6Dimension{100,40},BOXDROPDOWN}
7oCB:AddItem("Pig")
8oCB:AddItem("Cow")
9oCB:AddItem("Horse")
10oCB:Show()
This example creates a combo box with different currencies, showing an explicit representation to the user but using a different representation internally:
1METHOD Init(...) CLASS OrderWindow
2...
3oCBCurrency := ComboBox{SELF,CBCURRENCY_ID}
4oCBCurrency:FillUsing({;
5{"U.S. Dollars","USD"},;
6{"Can. Dollars","CDN"},;
7{"Mexican Pesos","MEX"},;
8{"Yen","YEN"},;
9{"British Pounds","UK"},;
10{"German Marks","DM"};
11})
12oCBCurrency:Show()
This example creates a combo box that shows the products available in the product table:
1METHOD Init(...) CLASS OrderWindow
2...
3oCBProducts := ComboBox{SELF,CBPRODUCTS_ID}
4oCBProducts:FillUsing(oDBProducts,#ProdName,#ProdNo)
5oCBProducts:Show()
See Also