Description
When a ListBox has been populated with the DirList function, DirSelect retrieves the current selection and stores it in a string variable.
Applies to
ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox controls
Syntax
listboxname.DirSelect ( selection )
Argument |
Description |
---|---|
listboxname |
The name of the ListBox control from which you want to retrieve the current selection. The ListBox must have been populated using DirList, and the selection must be a drive letter, a file, or the name of a directory. |
selection |
A string variable in which the selected path name will be put. |
Return value
Boolean.
Returns true if the current selection is a drive letter or a directory name (which can contain files and other directories) and false if it is a file (indicating the user's final choice). If any argument's value is null, DirSelect returns null.
Usage
Use DirSelect in the SelectionChanged event to find out what the user chose. When the user's selection is a drive or directory, use the selection as a new directory specification for DirList.
Examples
The following script for the SelectionChanged event for the ListBox lb_FileList calls DirSelect to test whether the user's selection is a file. If not, the script joins the directory name with the file pattern, and calls DirList to populate the ListBox and display the current drive and directory in the StaticText st_FilePath. If the current selection is a file, other code processes the file name:
string ls_filename, ls_filespec = "*.TXT" IF lb_FileList.DirSelect(ls_filename) THEN //If ls_filename is not a file, //append directory to ls_filespec. ls_filename = ls_filename + ls_filespec lb_filelist.DirList(ls_filename, & 16400, st_FilePath) ELSE ... //Process the file. END IF
See also