Article ID: 136640
Article Last Modified on 8/27/2002
* Init Code
SCAN
THIS.DISPLAYVALUE = <field name>
IF THIS.LISTINDEX = 0 && not already in the list
THIS.ADDITEM(<field name>)
ENDIF
ENDSCAN
THISFORM.REFRESH
If a new item is typed into the combo box, it must be verified as unique
before being added to the current list. To force the ListIndex property to
change automatically, add the following code to the Valid event procedure
of the combo box:
* Valid Code
THIS.VALUE = THIS.DISPLAYVALUE
IF THIS.LISTINDEX = 0 && Not already in the list
THIS.ADDITEM(THIS.VALUE)
THIS.DISPLAYVALUE = THIS.VALUE
ENDIF
The code assigns the DisplayValue property to the Value property for the
combo box. Then it checks the value of ListIndex. If ListIndex is 0, the
item is added as before. When this comparison is made, the DisplayValue
property loses its contents, so the Value property is reassigned to the
DisplayValue property in the IF...ENDIF structure.
Additional query words: VFoxWin akz
Keywords: KB136640