garylafferty
Programmer
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;
directorylistbox1.opencurrent;
end;
end;
I had hoped that this code would work, but it doesn't!
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.
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;
directorylistbox1.opencurrent;
end;
end;
I had hoped that this code would work, but it doesn't!
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.