How To Get Full Path of Item Selected in List Box (195409)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Macintosh 3.0b

This article was previously published under Q195409

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:

  1. Create a new form.
  2. Add a list box and a command button to the form.
  3. Set the following properties for the list box:
          RowSourceType=7     (for Files)
          RowSource=C:\*.*    (to show all files in root of C:\)
    							
  4. 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
    							
  5. Save and run the form.
  6. In the list box, navigate into the directory of your choice and select a file.
  7. 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.

Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbContainer kbCtrl kbhowto kbOOP KB195409