User Tools

Site Tools


k6:k6.9:k6.9.1:start

6.9.1 DirBox

The unobtrusive DirBox (gb.form) control implements a directory selection box:

B1
Figure 6.9.1.1: DirBox control with other controls (FileView and FileProperties)

The selection dialogue for a directory is started by clicking on the directory symbol at the right end of the text field of the DirBox - marked in red:


Figure 6.9.1.2: Selection dialogue with selected directory “DBAdressen”.

The selected directory is taken over with “Select”. The directory path is then in the text field of the directory selection box. The text field has the property “ReadOnly”. The control element can be created:

Dim hDirBox As DirBox
hDirBox = New DirBox ( Parent As Container ) As "EventName"

6.9.1.1 Properties

The DirBox class has these two properties, among others:

PropertyData typeDescription
BorderBooleanIndicates whether a border is set (default) or removes an existing border with the value 'False'.
ValueStringReturns the path to the selected directory or sets the (start) directory in the source code. If you do not specify a start directory, the home directory is automatically preset.

Table 6.9.1.1 : Properties of the DirBox class

6.9.1.2 Events

The DirBox class has these events, among others:

EventDescription
Click()This event is triggered when a user has selected a directory. The path to the selected directory is in the text field (property “ReadOnly”) of the DirBox.
Change()This event is synonymous with the Click event.

Table 6.9.1.2.1 : Events of the DirBox class

6.9.1.3 Accessing the directory path in DirBox

You can read the value of the DirBox.Value property and store it in a variable sDirPath, for example.

' Gambas class file
 
Public sDirPath As String
 
Public Sub Form_Open()
 
  FMain.Resizable = False
  DirBox1.Value = User.Home ' (Start-)Folder
  sDirPath = DirBox1.Value
  lblDirPath.Text = DirBox1.Value
  FileView1.Dir = DirBox1.Value
  FileView1.ShowPreview = True
  FileView1.ShowHidden = True
  FileView1.Background = &HC3DDFF
  FileView1.Foreground = Color.Red
  FileView1.Mode = Select.Single
  FileView1.Filter = ["*.txt", "*.png", "*.pd*", "*.jp*", "*.xml"]
  FileView1.IconSize = 48 ' Default-Value = 32
  FileProperties1.Path = DirBox1.Value
 
End
 
Public Sub DirBox1_Change()
 
  sDirPath = DirBox1.Value
  FileView1.Dir = DirBox1.Value
  lblDirPath.Text = DirBox1.Value
 
End
 
Public Sub FileView1_Click()
 
  FileProperties1.Path = sDirPath &/ FileView1.Current
 
End

Controls of the Dialog class (gb.qt4) for selecting files or directories such as OpenFile or SelectDirectory or SaveFile for saving files are described in Chapter 12.

Download

Project

Download

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.1/start.txt · Last modified: 16.01.2022 (external edit)

Page Tools