How to Simulate a Combo Box in FoxPro for WindowsLast reviewed: April 30, 1996Article ID: Q124779  | 
	
	
 
The information in this article applies to:
 
 SUMMARYA combo box is a object into which you can enter data directly or select an item from a predefined drop-down list. FoxPro does not have a combo box option to choose when making a screen, but you can use the technique presented in this article to simulate a combo box in FoxPro. 
 MORE INFORMATIONThe code in the VALID clause of the GET object will vary depending on where the information for the drop-down list comes from: arrays, a field from a table, or defining bars for the popup box. Use the following steps to make a combo box by using a popup with a predefined list: 
 Adjust the coordinates in the DEFINE POPUP statement if you want the popup to overlay the get field exactly. The example code shows how to define bars for the popup. If you want information from a field to be listed in the popup, change the code as indicated below. NOTE: This code uses the CUSTOMER.DBF file located in the TUTORIAL subdirectory of FoxPro. In the VALID clause of the COMBO GET object, change the code to match this: 
    IF EMPTY(combo)
      DEFINE POPUP combobox PROMPT FIELD cno FROM 6,29 TO 12,43
      ON SELECTION POPUP combobox DO getcombo
      ACTIVATE POPUP combobox
   ENDIF
   SHOW GETS
In the cleanup code, change the code to match this:
    PROCEDURE getcombo
   combo=<fieldname>     && This is the fieldname that follows the PROMPT
                         && FIELD clause in the DEFINE POPUP
   KEYBOARD '{TAB}'
This revised code fills the popup with the information from all the records
in that table of that field. Again, to position the popup on the screen
where you want it, experiment with the numbers of the DEFINE POPUP
statement.
  | 
	
	Additional reference words: FoxWin SBuilder 2.60a 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use.  |