Purpose |
Manipulate a COMBOBOX control in order to set/retrieve data. |
Syntax |
COMBOBOX ADD hDlg,
id&, StrExpr
[TO datav&] |
hDlg |
|
id& |
The control identifier assigned with CONTROL ADD COMBOBOX. |
item& |
Position of data in the COMBOBOX. First string=1, second=2... |
NumExpr |
A numeric expression passed as a parameter. |
StrExpr |
A string expression passed as a parameter. |
txtv$ |
A
|
datav& |
A long integer variable to which result data is assigned. |
Remarks |
In each of the following samples and descriptions, the COMBOBOX control which is the subject of the statement is identified by the handle of the dialog that owns the COMBOBOX (hDlg), and the unique control identifier you gave it upon creation in CONTROL ADD COMBOBOX. COMBOBOX ADD hDlg, id&, StrExpr [TO datav&] The string value specified by StrExpr is added to the COMBOBOX control. If the COMBOBOX has the %CBS_SORT style, the new string is inserted in alphanumeric order; otherwise it is added to the end of the existing list. If the optional TO clause is included, the index position of the added string is assigned to the variable represented by datav&. The index is one for the first string, two for the second, etc. If the index is less than one, an error occurred and no string was added. COMBOBOX DELETE hDlg, id&, item& The string at the position specified by item& is deleted from the COMBOBOX. The item number (item&) is indexed to one (1=first, 2=second, and so on). COMBOBOX FIND hDlg, id&, item&, StrExpr TO datav& Strings in the COMBOBOX are searched to find the first string which begins with the data in StrExpr, regardless of any characters which follow. Comparisons are not case-sensitive. Strings are searched beginning with the string specified by item&, and ending with the last string in the COMBOBOX. Searching does not wrap to the beginning of the list. The item number (item&) is indexed to 1 (1=first, 2=second, etc.). To search the entire COMBOBOX starting with the first string, item& should be set to one (1). If a matching string is found, the index value of the match is assigned to the variable specified by datav&. If no match is found, the value zero (0) is assigned to it. COMBOBOX FIND EXACT hDlg, id&, item&, StrExpr TO datav& Strings in the COMBOBOX are searched to find the first string which exactly matches the data in StrExpr. Comparisons are not case-sensitive. Strings are searched beginning with the string specified by item&, and ending with the last string in the COMBOBOX. Searching does not wrap to the beginning of the list. The item number (item&) is indexed to 1 (1=first, 2=second, etc.). To search the entire COMBOBOX starting with the first string, item& should be set to one (1). If a matching string is found, the index value of the match is assigned to the variable specified by datav&. If no match is found, the value zero (0) is assigned to it. COMBOBOX GET COUNT hDlg, id& TO datav& The number of items in the list box of the COMBOBOX is retrieved, and assigned to the long integer variable specified by datav&. COMBOBOX GET SELCOUNT hDlg, id& TO datav& The number of selected items in the list box of the COMBOBOX is retrieved, and assigned to the long integer variable specified by datav&. Since this is a single-selection list box, the retrieved value will always be either zero or one. COMBOBOX GET SELECT hDlg, id& TO datav& The index of the currently selected item in the list box of the COMBOBOX is retrieved, and assigned to the variable specified by datav&. The index is 1 for the first item, 2 for the second item, etc. If there is no current selection, the value zero (0) is assigned. COMBOBOX GET STATE hDlg, id&, item& TO datav& A data item is checked to see if it is currently selected. The numeric value item& specifies which user value is to be checked, 1 for the first item, 2 for the second item, etc. If the item is selected, -1 (true) is assigned to the variable specified by datav&. Otherwise, 0 (false) is assigned to it. COMBOBOX GET TEXT hDlg, id& [,item&] TO txtv$ Text is retrieved from the COMBOBOX and assigned to the string variable specified by txtv$. If the numeric expression item& is included, it determines which text string is returned, 1 for the first item, 2 for the second item, etc. If item& is missing, or contains the value zero, the selected text is returned (or an empty string if none is selected). If you wish to retrieve the text found in the edit box portion of the COMBOBOX (regardless of whether it was typed or selected), you should use the CONTROL GET TEXT statement instead. COMBOBOX GET USER hDlg, id&, item& TO datav& Each item in a COMBOBOX may have a long integer user value associated with it at the discretion of the programmer. This user value is retrieved with COMBOBOX GET USER. The numeric value item& specifies which user value is requested, 1 for the first item, 2 for the second item, etc. The returned user value is assigned to the long integer variable specified by datav&. COMBOBOX user values are assigned with the COMBOBOX SET USER statement. In addition to these COMBOBOX user values, every DDT control offers an additional eight user values which can be accessed with CONTROL GET USER and CONTROL SET USER. COMBOBOX INSERT hDlg, id&, item&, StrExpr [TO datav&] The text for a new data item, specified by StrExpr, is inserted at the location given by item&. The value of item& = 1 for the first item, 2 for the second item, etc. The list of data items is not re-sorted, even if the COMBOBOX was created with the style %CBS_SORT. If you wish to sort all of the items, use COMBOBOX ADD instead. If the optional TO clause is included, the index position of the inserted string is assigned to the variable represented by datav&. The index is one for the first string, two for the second, etc. If the index is less than one, an error occurred and no string was inserted. COMBOBOX RESET hDlg, id& Delete all contents of the specified COMBOBOX. COMBOBOX SELECT hDlg, id&, item& The string value specified by item& is chosen as selected text for the COMBOBOX control, and the selected text is scrolled into a visible position. The value of item& = 1 for the first item, 2 for the second item, etc. COMBOBOX SET TEXT hDlg, id&, item&, StrExpr The text for the data item specified by item& is replaced with the new text in StrExpr. The value of item& = 1 for the first item, 2 for the second item, etc. The list of data items is not re-sorted, even if the COMBOBOX was created with the style %CBS_SORT. If you wish to sort all of the items, use COMBOBOX DELETE followed by COMBOBOX ADD instead. COMBOBOX SET USER hDlg, id&, item&, NumExpr Each item in a COMBOBOX may have a long integer user value associated with it at the discretion of the programmer. This user value is assigned with COMBOBOX SET USER, and retrieved with COMBOBOX GET USER. The numeric value item& specifies which user value is to be accessed, 1 for the first item, 2 for the second item, etc. The value specified by NumExpr is saved for later retrieval. In addition to these COMBOBOX user values, every DDT control offers an additional eight user values which can be accessed with CONTROL GET USER and CONTROL SET USER. COMBOBOX UNSELECT hDlg, id& All items in a COMBOBOX control are set to an unselected state. |
Restrictions |
Under Windows 95/98/ME, a list box is limited to 32,767 items. In all versions of Windows, the actual string data contained by the list box is limited only by available memory. |
See also |
Dynamic Dialog Tools, CONTROL ADD COMBOBOX, CONTROL GET TEXT |