Column_Combo_Find - DfBaseEntryList
Searches for an item in the dropdown list of a combo form for a column by value
Type: Function
Return Data Type: integer
Parameters
| Parameter | Type | Description |
|---|---|---|
| iColumn | integer | The column number (0-based) |
| iStart | integer | Starting item position to search (0-based) |
| sFindValue | string | Value to find in list |
Syntax
Function Column_Combo_Find integer iColumn integer iStart string sFindValue Returns integer
Call Example
Get Column_Combo_Find iColumn iStart sFindValue to integerVariable
Description
Searches for an item in the dropdown list of a combo form for a column by value. You can use the starting position (iStart) to search for duplicates. Note that the combo value to be found must be an exact match to the item in the list, in both length and casing.
Sample
This sample fills a grid with 20 rows of 2 columns each. The first column (column 0) is filled alternatingly with values John, Anne and Judy. It then instructs the grid to make column 0 a combo form, to sort the combo form's dropdown list, and adds 7 items to the dropdown list of the combo form. When button oButton1 is clicked, it finds the first occurence of John in the list for the current column's combo form dropdown list and displays it in a message box.
Object oGrid1 is a Grid
:
Procedure DoFillGrid
integer iRow iMaxRows iCount
move 20 To iMaxRows
For iRow From 1 To iMaxRows
if (mod(iCount,3)=0) Send Add_Item Msg_None "John"
else if (mod(iCount,3)=1) Send Add_Item Msg_None "Anne"
else Send Add_Item Msg_None "Judy"
Send Add_Item Msg_None ("305-555-1212")
increment iCount
Loop
End_Procedure // DoFillGrid
send DoFillGrid
// make column 0 a combo
set Column_Combo_State 0 to True
// sort the dropdown list for the combo in column 0
set Column_Combo_Sort_State 0 to True
// add items to the dropdown list for the combo in column 0
Send Column_Combo_Add_Item 0 "Anne"
Send Column_Combo_Add_Item 0 "Elizabeth"
Send Column_Combo_Add_Item 0 "Albert"
Send Column_Combo_Add_Item 0 "John"
Send Column_Combo_Add_Item 0 "Doug"
Send Column_Combo_Add_Item 0 "Judy"
Send Column_Combo_Add_Item 0 "David"
End_Object // oGrid1
Object oButton1 is a Button
:
Procedure OnClick
integer iColumn iStart iFoundItem
string sValue
move 0 to iColumn
move 0 to iStart
move "John" to sValue
get Column_Combo_Find of oGrid1 iColumn iStart sValue to iFoundItem
if (iFoundItem <> -1) ;
send Info_Box ("Value "+sValue+" was found in item "+string(iFoundItem)) "Value found"
End_Procedure // OnClick
:
End_Object // oButton1
Return Value
Returns the item number from the unsorted list or -1 if the search fails.