Article ID: 142190
Article Last Modified on 10/15/2003
APPLIES TO
- Microsoft Visual FoxPro 3.0 Standard Edition
- Microsoft Visual FoxPro 3.0b Standard Edition
- Microsoft Visual FoxPro 6.0 Professional Edition
This article was previously published under Q142190
SUMMARY
Moverlist boxes are designed to allow for easy point selection of a value that will display in a parallel list box enabling the user to create a list of items before proceeding. The code involved to make these list boxes work properly is very extensive in the Microsoft Visual FoxPro product. In the Vfp\Samples\Controls\Samples.vcx directory, you'll find a Mover Class that you can use to quickly create moverlist boxes with very little additional code. The example given in this article works for most, if not all, users.
MORE INFORMATION
Step-by-Step Example
- Start a Visual FoxPro session.
- On the Tools menu, click Options, and then click the Controls tab.
Make sure the Visual Class Libraries option is selected, and then click Add, and select the following library:
Vfp\Samples\Controls\Samples.vcx
Samples should appear in the Selected box of the Options Dialog Box,
- Click Set As Default, then click OK.
- On the system's File menu, click New, click Form, and click New File. A blank form will appear.
- Click the View Classes Button on the Forms Control Tool Bar, and select Samples. The Forms Control Tool Bar has now changed.
- Click the Moverlists Button, click in the form, and the moverlists will appear.
- Place the table that you intend to get the list value(s) from in the Data Environment of the form.
Place the following code in the Init event of the form:
SELECT <TABLENAME> SCAN THIS.MOVERLISTS1.LSTSOURCE.ADDLISTITEM(<FIELDNAME>) ENDSCAN
At this point, you can add any additional buttons, controls, or code depending on what the user would like the list boxes to do.
Steps to Add Selected Items to a Database
If you want to add the selected values to a .dbf file, follow these steps:
- Add the .dbf table to Data Environment of the form.
Add a Command Button, and place the following code in its Click Event:
SELECT <NEWTABLENAME> FOR I = 1 TO THIS.PARENT.MOVERLISTS1.LSTSELECTED.LISTCOUNT APPEND BLANK REPLACE <FIELDNAME> WITH ; THIS.PARENT.MOVERLISTS1.LSTSELECTED.LISTITEM(I) ENDFOR
The records that were selected have now been written to the table of your choice.
To immediately see the results of the APPEND command, add:
BROWSE
Additional query words: VFoxWin
Keywords: kbcode KB142190