User Tools

Site Tools


6.9.3 DirChooser

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. Properties

The DirChooser class has these selected properties:

PropertyData typeDescription
DirView DirViewReturns the DirView control used internally by the DirChooser.
FileView FileViewReturns the FileView control used internally by the DirChooser.
Icon PictureReturns or sets the icon for displaying a file or directory. Use this property to react to the icon event.
PicturePictureReturns or sets the picture used for the root directory.
SelectedPath StringReturns the selected directory path.
ValueStringSynonym for the SelectedPath property.
ShowBookmarkBooleanReturns or sets the truth value whether the bookmark field is visible or not.
ShowDetailedBooleanReturns the truth value or sets the truth value whether the files are displayed with a detail view or with icons or not.
ShowFileBooleanReturns the truth value or sets the truth value whether the panel showing the contents of the directory is shown or hidden.
ShowHiddenBooleanReturns or sets the truth value whether the hidden files or directories are shown or hidden.
ShowPreviewBooleanReturns the truth value or sets the truth value whether the thumbnails are shown or not.
ShowSplitterBooleanReturns the truth value or sets the truth value whether the splitter button is visible.

Table : Properties of the DirChooser class.


  • You get project-wide access to the selected directory via the value of the property DirChooser.SelectedPath, which you also store in a (public) variable sDirPath, for example.
  • It makes sense when selecting a directory if you recognise the content of the selected directory. For example, first set the ShowFile properties in the source code and then also set ShowHidden, ShowPreview or ShowDetailed to True.
  • Alternatively, you can also set the property DirChooser.ShowSplitter to True. Even then, you have the option of specifying additional display options via the context menu.
  • Note that you can define bookmarks for the runtime of the programme in the context menu if you have set the property DirChooser.ShowBookmark to True.
  • For a detailed description of the use of bookmarks, see the chapter describing the FileChooser control. Methods

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. Events

The DirChooser class has these selected events, among others:

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 : Selected events of the DirChooser class.


You can create new directories via the context menu or trigger the creation via the following source code:

Public Sub btnCreateNewFolder_Click()

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()

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

Figure 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 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:

Figure Context menu




The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k6/k6.9/k6.9.3/start.txt · Last modified: 16.01.2022 (external edit)

Page Tools