DrivePath Control (VBCCRDrivePath)
The VBCCRDrivePath control provides an interface for browsing and selecting drive paths. It allows users to browse drives on the computer and select specific paths, typically used in conjunction with the FilePath control.
Properties
Key Properties
Path
: Currently selected pathDrive
: Currently selected drivePattern
: File filter patternEnabled
: Enable/disable controlBackColor
: Background colorForeColor
: Text colorReadOnly
: Whether in read-only modeShowNetwork
: Whether to display network drives
Methods
Main Methods
Refresh()
: Refresh drive listChange()
: Change current pathSetFocus()
: Set focus to control
Events
Change()
: Triggered when path changesClick()
: Triggered when clickedPathClick()
: Triggered when path is clickedPathChange()
: Triggered when path change completesDriveChange()
: Triggered when drive changes
Code Examples
Basic Usage
vb
Private Sub Form_Load()
With DrivePath1
.Path = "C:\"
.ShowNetwork = True
.Enabled = True
End With
End Sub
Monitoring Path Changes
vb
Private Sub DrivePath1_Change()
Debug.Print "Current path: " & DrivePath1.Path
End Sub
Private Sub DrivePath1_DriveChange()
Debug.Print "Current drive: " & DrivePath1.Drive
End Sub
Integration with FilePath Control
vb
Private Sub SyncPathControls()
' Synchronize DrivePath and FilePath controls
FilePath1.Path = DrivePath1.Path
End Sub
Private Sub DrivePath1_PathChange()
SyncPathControls
End Sub
Common Use Cases
File Browser
vb
Private Sub SetupFileBrowser()
' Set up drive browser
With DrivePath1
.Path = App.Path
.ShowNetwork = True
.Pattern = "*.txt;*.doc;*.docx"
End With
End Sub
Private Sub DrivePath1_PathClick()
' Update file list
UpdateFileList DrivePath1.Path
End Sub
Backup Location Selector
vb
Private Sub SetupBackupLocationSelector()
With DrivePath1
.ShowNetwork = True
' Check default backup path