| Re: question about directory list boxes -
06-04-2007, 10:33 AM
See inline :-
On Tue, 26 Dec 2006 11:38:01 +1100, "Antony Clements"
<EMAIL REMOVED> wrote:
>i have written a program that incorporates the following code.
>
>Private Sub Dir1_Change()
> 'changes the folder and displays each file in the folder
> On Error Resume Next
> File1.Path = Dir1.Path
> RaiseEvent DirectoryChanged(Dir1.Path)
> File1.Selected(0) = True
> frmMain2.lblFileIn.Caption = Dir1.Path
> frmMain2.lblFileOut.Caption = Dir1.Path
>End Sub
>
>is there any way i can modify this code to also work with a keypress event?
>
>i have tried the following, but it doesn't work.
>
>Private Sub Dir1_KeyPress(KeyAscii As Integer)
> On Error Resume Next
> If KeyAscii = vbKeyReturn Then
Dir1.Path = Dir1.List(Dir1.ListIndex) '<=== Add This ===
> File1.Path = Dir1.Path
> RaiseEvent DirectoryChanged(Dir1.Path)
> File1.Selected(0) = True
> frmMain2.lblFileIn.Caption = Dir1.Path
> frmMain2.lblFileOut.Caption = Dir1.Path
> End If
>End Sub
The highlighted Directory is NOT the selected Directory, that only
happens with a double click.
If I were you I would wrap this in a UserControl, it is the sort of
thing that you will probably want to re-use. |