Question:
How can I dynamically add or delete entries from a list box, popuplist or combo box?
Answer:
List boxes, popup lists and combo boxes all use the Translationproperty. The Translation property gives all of these list-typeobjects the ability to display one value to the user while using adifferent value for the selection. For instance, a combo box coulddisplay the name of an employee, while the actual Value property isthe employee’s identification number.
You can set the display and internal values for a list-type object byassigning database columns for the display and internal values, byassigning an SQL statement to the Translation property that returns acolumn for the display and internal values, or by creating a textlist where the display value and the internal value are each listedon a separate line with an “=” sign between them, as illustratedbelow.
Aaron = A
Bobby = B
Cathy = C
The techniques described below allow you to add entries or deleteentries from list-type objects that use a value list in theTranslation property.
To dynamically add entries to a list-type object, you can dynamicallyreset the Translation property of the object. In the code examplebelow, the display value, represented by the vsDisplay variable, the”=” sign and the internal value, represented by vsValue, areconcatenated onto the end of the Translation property for thelstSample list box.
DIM sNewLine As StringsNewLine = CHR(13) & CHR(10)lstSample.Translation = lstTranslation & sNewLine & & vsDisplay & "=" & vsValue
Before the values are added to the Translation property, a new linecharacter and a carriage return character are added to the end of theproperty to indicate a new entry is about to begin. The CHR()function assigns the value of the ASCII character for the charactersto the sNewLine variable, which is added to the Translation propertybefore the new values.
Setting the Translation property will cause the list-type object toautomatically re-populate itself.
You can also use string manipulation methods to delete values fromthe Translation property. You would find the current Value of thelist-type object in the Translation string, find the
Note: In version 1 of Oracle Power Objects, a bug causes a list boxto not completely clear a list box once you delete the final entry inthe Translation property.