Skip to content

ComboAddItem - cCJGridColumn

Send ComboAddItem to add a name/value pair to the column's combo list

Type: Procedure

Parameters

Parameter Type Description
sCaption String The value displayed in the combo list
iData Integer Unique numeric value representing the combo item

Syntax

Procedure ComboAddItem String sCaption Integer iData

Call Example

Send ComboAddItem sCaption iData

Description

Sample

In this sample, a grid column is created with a combo list containing six members (Int, Char, DateTime, Number, Binary and Text).

Object oType is a cCJGridColumn 
    Set psCaption to "Type"
    Set piWidth to 59
    Set pbComboButton to True
    Set pbComboEntryState to False

    Send ComboAddItem "Int" 0
    Send ComboAddItem "Char" 2
    Send ComboAddItem "DateTime" 3
    Send ComboAddItem "Number" 4
    Send ComboAddItem "Binary" 5
    Send ComboAddItem "Text" 6
End_Object

To enable combo lists for the column cells, you must set the column's pbComboButton property to True.

To delete all members in the combo list, send ComboDeleteData.

To retrieve the full set of combo name/value pairs, use the ComboData method.

The data values that are displayed and retrieved from a column that uses a combo list are the values in the sCaption parameter. The iData values are used internally by the CodeJock grid control's ReportRecordItemConstraints object.

Sample

If you are dynamically initializing the combo list in a data-aware grid column (cDbCJGridColumn) and want to save the iData value, rather than the sCaption value, you will have to manually retrieve the data using ComboFindItem and/or ComboData and update the column value of the selected row using UpdateCurrentValue.

The sample below shows how to do this if you added a column named Foo to the Order Detail table in the Order Entry sample workspace.

Object oOrderDtl_Foo is a cDbCJGridColumn 
    Entry_Item OrderDtl.Foo
    Set psCaption to "Foo"
    Set piWidth to 59
    Set pbComboButton to True
    Set pbComboEntryState to False

    Procedure OnEntry
        Send ComboDeleteData

        Send ComboAddItem "x1 option" 1
        Send ComboAddItem "x2 option" 2
        Send ComboAddItem "x3 option" 3
        Send ComboAddItem "x4 option" 4

        Forward Send OnEntry
    End_Procedure

    Procedure OnEndEdit String sOldValue String sNewValue
        Forward Send OnEndEdit sOldValue sNewValue

        Integer iPos
        tComboItemData[] ItemData

        Get ComboFindItem 0 sNewValue to iPos
        If (iPos <> -1) Begin
            Get ComboData to ItemData
            Send UpdateCurrentValue ItemData[iPos].iData
        End
    End_Procedure
End_Object

See Also

pbComboEntryState | pbShowNonActiveInPlaceButton