Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directorylistbox : moving to a specified sub-directory 1

Status
Not open for further replies.

garylafferty

Programmer
May 1, 2002
8
GB
Hi,

I have a directorylistbox showing all the sub-directories in my C: drive, and an associated filelistbox showing all the files in the selected directory.

How can I move to a specified sub-directory within the directorylistbox, so that the filelistbox will then automatically show all the files in that sub-directory ?

I have used the code below as a start:



var
y : integer;
stringvar : string;


begin

stringvar:='compaq';

for y:=0 to (directorylistbox1.items.count -1) do
begin
if directorylistbox1.items[y]=stringvar then
begin
form1.caption:=directorylistbox1.getitempath(y);
directorylistbox1.opencurrent;
end;
end;




I had hoped that this code would work, but it doesn't! [sadeyes]

The form1.caption will show 'c:\compaq' , but the filelistbox shows the files in 'c:\' , as the directorylistbox hasn't MOVED to the c:\compaq sub-directory, to enable opencurrent to work.

Can anyone tell me what I'm doing wrong, or suggest a possible solution to this problem ? It would be very much appreciated.

 
How about adding this to the OnChange event of the DirectoryListBox:

FileListBox1.Directory := DirectoryListBox1.Directory;

Have a look in the delphi help under TFileListBox.Directory and take a look at the example. Clive [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top