HOWTO: Get Full Path of Item Selected in List Box
ID: Q195409
|
The information in this article applies to:
-
Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a, 6.0
-
Microsoft Visual FoxPro for Macintosh, version 3.0b
SUMMARY
This article shows how to obtain the full path of a file chosen in a list
box or combo box control that has a RowSourceType property set to 7-Files.
MORE INFORMATION
You can use the ListItem property to obtain the path of the file selected.
The ListItem property is a character string array used to access the items
in a combo box or list box control by item ID. An item ID of two (2) is the
full path to the directory for which files are currently being shown in the
list box. An item ID of one (1) is just the drive.
The following steps create a form to illustrate these concepts:
- Create a new form.
- Add a list box and a command button to the form.
- Set the following properties for the list box:
RowSourceType=7 (for Files)
RowSource=C:\*.* (to show all files in root of C:\)
- Place the following code in the Click event of the command button:
WAIT WINDOW Thisform.list1.Value
WAIT WINDOW Thisform.list1.ListItem(2)+Thisform.list1.Value
- Save and run the form.
- In the list box, navigate into the directory of your choice and select a
file.
- Click the command button. The first WAIT WINDOW displays the Value
property of the list box. The second WAIT WINDOW displays the
ListItem(2) value of the list box concatenated with the Value property.
Additional query words:
Keywords : kbContainer kbCtrl kbMAC kbOOP kbVFp kbVFp300b kbVFp500 kbVFp500a kbVFp600
Version : MACINTOSH:3.0b; WINDOWS:3.0,3.0b,5.0,5.0a,6.0
Platform : MACINTOSH WINDOWS
Issue type : kbhowto