How to use choice and combo box controls on a form.
You can run this technique code from:
NOTE First make sure that database is running on your localhost SilverStream Server | |
See the chapter on the Form Designer in the Tools Guide |
The following code uses getSelectedIndex()
to get the index value of a currently selected row in the choice control cbCompanies. It then uses getRowText()
to get the string value, and uses setText()
to place this value in the text field fldChoiceRowText. It also gets the storage value using getRowValue()
and places this value in fldChoiceRowValue.
This code is in the valueChanged event for the choice box chCompanies:
// Get the index of the selected row int index = chCompanies.getSelectedIndex(); // Valid row selected? if (index != -1) { // Yes, so get the display value of the selected row, // and display this in fldChoiceRowText fldChoiceRowText.setText(chCompanies.getRowText(index)); // Get the storage value of the selected row Integer rowValue = (Integer) chCompanies.getRowValue(index); // Display the storage value in fldChoiceRowValue fldChoiceRowValue.setText(rowValue.toString()); }
getSelectedIndex()
. It returns -1 if no row is currently selected.
getRowText()
and its storage value using getRowValue()
.
The following code uses the getText()
method to get the string value of a selected row in a combo box control tcbCompanies. Then, using setText()
, the code places the value in the text field fldComboRowText.
This code is in the valueChanged event for the combo box cbCompanies:
// Get the display value of the selected row, // and display this in fldComboRowText fldComboRowText.setText(cbCompanies.getText());
setText()
and getText()
accept a string, one method can be passed directly to the other.