The DirChooser control (gb.form) allows the user to select a directory. There is an additional option to also display the contents of a selected directory.
The control can be created:
Dim hDirChooser As DirChooser hDirChooser = New DirChooser ( Parent As Container ) As "EventName"
Internally, the DirView and FileView controls (optional) are used.
The DirChooser class has these selected properties:
Property | Data type | Description |
---|---|---|
DirView | DirView | Returns the DirView control used internally by the DirChooser. |
FileView | FileView | Returns the FileView control used internally by the DirChooser. |
Icon | Picture | Returns or sets the icon for displaying a file or directory. Use this property to react to the icon event. |
Picture | Picture | Returns or sets the picture used for the root directory. |
SelectedPath | String | Returns the selected directory path. |
Value | String | Synonym for the SelectedPath property. |
ShowBookmark | Boolean | Returns or sets the truth value whether the bookmark field is visible or not. |
ShowDetailed | Boolean | Returns the truth value or sets the truth value whether the files are displayed with a detail view or with icons or not. |
ShowFile | Boolean | Returns the truth value or sets the truth value whether the panel showing the contents of the directory is shown or hidden. |
ShowHidden | Boolean | Returns or sets the truth value whether the hidden files or directories are shown or hidden. |
ShowPreview | Boolean | Returns the truth value or sets the truth value whether the thumbnails are shown or not. |
ShowSplitter | Boolean | Returns the truth value or sets the truth value whether the splitter button is visible. |
Table 6.9.3.1.1 : Properties of the DirChooser class.
Notes:
The DirChooser class has only one relevant method, Reload( ). It reloads the contents of the view - as if you had clicked on the “Refresh” button in the context menu.
6.9.3.3 Events
The DirChooser class has these selected events, among others:
Event | Description |
---|---|
Activate( ) | The event is triggered when a user double-clicks on a directory. |
Change( ) | This event is triggered when the current directory changes. |
Icon( Path As String ) | This event is triggered when the icon for a specific file or directory of the control should be changed. The parameter “Path” is the file path to the icon. |
Table 6.9.3.3.1 : Selected events of the DirChooser class.
Notes:
You can create new directories via the context menu or trigger the creation via the following source code:
Public Sub btnCreateNewFolder_Click() DirChooser1.DirView.NewFolder() End
You change the name of an existing directory via the context menu or via the following source code, which triggers the change:
Public Sub btnRenameFolder_Click() DirChooser1.DirView.Rename() End
The following notes on the layout of the programme window and the basic configuration of the DirChoosers control have proven to be useful for practical use:
Public Sub Form_Open() FMain.Resizable = True FMain.Utility = True ' Minimum window size as defined in the IDE DirChooser1.Root = User.Home ' Default-Folder DirChooser1.ShowSplitter = True DirChooser1.ShowBookmark = True ... End
Figure 6.9.3.3.1: DirChooser with basic configuration
If you switch on the splitter, you will also see the contents of the selected directory in the internal FileView. In addition, the ToolBar fills with more buttons and controls like a slider to change the display size of the preview images.
Figure 6.9.3.3.2: DirChooser with extended configuration
You can also use the available context menu of the internal FileView to make further settings or actions. A nested context menu supports you in working with the DirChooser control:
Project