
cmbList.AddString(edNewString)
intIndex = cmbList.GetItemCount()
intIndex = intIndex - 1
cmbList.SetSelection(intIndex)
Note:
cmbList – a Form control, combo box.
edNewString – a Form control, edit control where the user can enter a new string.
intIndex – a Form variable, Integer variable.
cmbList.GetItemCount() – returns the number of elements in the list.
The new string will be added to the end of the list contained in the combo box and will be displayed in the combo box. The list index begins at 0.
IF cmbList.GetItemCount() == 0
{
cmbList.Disable()
}
ELSE
{
cmbList.Enable()
}
Note:
cmbList.GetItemCount() – returns the number of elements in the list.
cmbList – a Form control, combo box.
In this example if the list is empty the combo box will be disabled.
A disabled combo box will appear shaded out on the form.
IF cmbList.GetSelection() < 0
{
Form.MessageBox("Error", "No Selection", MB_OK)
}
ELSE
{
edOrderID = cmbList.GetCurrentRowColumnValue("ORDER_ID")
edProductName = cmbList.GetCurrentRowColumnValue("PRODUCT_NAME")
}
Note:
It is recommended to check that there is a selection before retrieving values.
cmbList.GetSelection() < 0 – Checks that an element has been selected. A return value of –1 means that there is no selection.
edOrderID and edProductName are edit controls and they will display the ORDER_ID and PRODUCT_NAME columns of the current selection.
IF boolShow == false
{
cmbList.Hide()
}
ELSE
{
cmbList.Show()
}
Note:
boolShow – Form variable, used as a flag in this instance to check whether to display or hide the label
cmbList – a Form control, combo box.
A combo box will not be visible on the form when it is hidden.
cmbList.Refresh()
Note:
cmbList – a Form control, combo box.
This expression will refresh the content on the combo box by re-running the query.
cmbList.Reset()
Note:
cmbList – a Form control, combo box.
This expression will clear the content of the combo box.
cmbList.SetFocus()
Note:
cmbList – a Form control, combo box.
This expression will set the form focus on the combo box.
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:
cmbList – a Form control, combo box.
The SQL query which is set in the first line is parameterised, with the condition containing a "?".
The SQL query returns the ID, NAME and ADDRESS columns, however, the column shown in the combo box will be whatever the existing column is.
In the second line, "Param1" refers to the parameter of the query in the first line. local.Variable is the value assigned to this parameter.
After the SQL query is set, the combo box must be refreshed for the changes to be visible to the user.
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:
cmbList – a Form control, combo box.
"ADDRESS" is the column name defined in the combo box's existing query.
After the column is set, the combo box must be refreshed for the changes to be visible to the user.