Here's an idea...although there MUST be a better way of doing it (I like the whole event driven-ness of this way, though)
For todays recipe, you will need:
A form containing;
1 x DriveListBox control
1 x DirListBox control
1 x FileListBox control
1 x ListBox control
First, set the FileListBox control Visible property to False. Although this control is neccessary, it's not going to be shown, so make it any size you like and put it anywhere on the form.
Now arrange the other three controls so that they look good to you.
Now, associate the following code with your form;
Private Sub Dir1_Change()
Me.File1.Path = Me.Dir1.Path
End Sub
Private Sub Drive1_Change()
Me.Dir1.Path = Me.Drive1.Drive
End Sub
Private Sub File1_PathChange()
Dim lngIndex As Long
Dim lngExtStart As Long
For lngIndex = 0 To Me.File1.ListCount - 1
lngExtStart = InStr(Me.File1.List(lngIndex), "."
If lngExtStart > 0 Then
Me.List1.List(lngIndex) = Mid(Me.File1.List(lngIndex), 1, lngExtStart - 1)
Else
Me.List1.List(lngIndex) = Me.File1.List(lngIndex)
End If
Next
End Sub
What happens here is this; Changing the DriveListBox path property (by clicking on it and changing it) will raise that control's Change event, which changes the path of the DirListBox control. This, in turn, raises that control's Change event, which changes the path property of the FileListBox control.
This is where the fun stuff happens. Unfortunately, a FileListBox is read only at runtime, so you can't modify its contents. However, what you can do is assign its contents to another control - the ListBox control in this case.
The PathChange event of the FileListBox control basically says;
Loop through all the items listed here
If an item contains a . character then assign that item to the ListBox control, missing off all the characters after and including the . character
Otherwise, just assign this item to the ListBox control as is
So your ListBox control takes the place of your FileListBox control and is just as flexible a control - more so, in fact, as you can modify its contents at runtime.
The only problem is that the LitsBox control will only update if its PathChange event is raised, which doesn't appear to happen when you first launch the form. It's probably not too hard to get around this, but I've not looked into it, sorry
plain black box</a><br>"Suffice it to say that adding disk drives and a disk operating system to a personal microcomputer is guaranteed to increase its power dramatically."<br>
<u><b>CP/M and the Personal Computer</u></b>[/sig]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.