Combo Box Examples

Example 1. Add a string to the drop down list and select the new entry.

cmbList.AddString(edNewString)

intIndex = cmbList.GetItemCount()

intIndex = intIndex - 1

cmbList.SetSelection(intIndex)

Note:

Example 2. Disable or enable a combo box.

IF cmbList.GetItemCount() == 0

{

    cmbList.Disable()

}

ELSE

{

    cmbList.Enable()

}

Note:

Example 3. Get current row and column values.

IF cmbList.GetSelection() < 0  

{

    Form.MessageBox("Error", "No Selection", MB_OK)

}

ELSE

{

    edOrderID = cmbList.GetCurrentRowColumnValue("ORDER_ID")

    edProductName = cmbList.GetCurrentRowColumnValue("PRODUCT_NAME")

}

Note:

Example 4. Hide or show a combo box.

IF boolShow == false           

{

    cmbList.Hide()

}

ELSE

{

    cmbList.Show()

}

Note:

Example 5. Refresh a combo box.

cmbList.Refresh()

Note:

Example 6. Reset a combo box.

cmbList.Reset()

Note:

Example 7. Set focus on the combo box.

cmbList.SetFocus()

Note:

Example 8. Changing the combo box query

The query retrieving the combo box records may be changed in BrightBuilder using the SetSql() method. If the query is parameterised, the parameter may also be changed using the SetSqlParam() method after the query has been defined.

cmbList.SetSql("select ID, NAME, ADDRESS from table1 where ID > ?");

cmbList.SetSqlParam("Param1", local.Variable);

cmbList.Refresh()

Note:

Example 9. Changing the combo box display column

A query column must be defined when a query is attached to a combo box. This column may be changed using the following code in an expression.

combo_box1.SetDisplayColumn("ADDRESS");

cmbList.Refresh()

Note: