The Select (gb.qt4) class provides three constants (→ Table 20.9.1.1) for specifying the mode properties of many components. These components include:
ColumnView, DateBox, DateChooser, FileView, GridView, IconView, LCDNumber, ListBox, ListView, Stat, TableView, TreeView and _TreeView.
Select | Constant | Description |
---|---|---|
None | 0 | No selection of elements is possible for the selected component. |
Single | 1 | The component allows single selection (default). |
Multiple | 2 | Multiple selection is possible for the selected component by holding down the CTRL key or SHIFT key (block). |
Table 20.9.1.1: Constants of the Select Class
In the project presented, two constants (Select.Single and Select.Multiple) are used to specify the file selection options in the FileView component:
Figure 20.9.2.1: Mode: Select.Single
Figure 20.9.2.2: Mode: Select.Multiple
Notes:
The source code is manageable and is therefore given in full:
' Gambas class file Private myStatusbar As Statusbar Public Sub Form_Open() FMain.Center() FMain.Resizable = False DirView1.Root = User.Home txbDirectory.Text = DirView1.Current txbFile.Clear() Timer1.Delay = 1000 Timer1.Start() myStatusbar = New Statusbar(Me) myStatusbar.Add(0.3, Format$(Now, "dddd, dd/mm/yyyy hh:nn:ss")) '-- 0.3 → 30% of the StatusBar width myStatusBar.SetBackground(0, &HEFFFDF) myStatusBar.SetForeground(0, &H000000) myStatusbar.SetToolTip(0, "Datum&Zeit") myStatusbar.SetAlignment(0, Align.Center) myStatusbar.Add(0.3, "Select-Mode: Select.Single") '-- Start setting myStatusBar.SetBackground(1, &HFFFFDF) myStatusbar.SetAlignment(1, Align.Center) ' -- The field length is automatically set at the last field → enter 0 myStatusbar.Add(0, "Program version = " & Application.Version) myStatusBar.SetBackground(2, &HEFFFDF) myStatusbar.SetAlignment(2, Align.Center) btnFileSelectMode.Picture = Picture["Symbols/multiple.png"] btnFileSelectMode.Value = False End Public Sub Timer1_Timer() '-- Timer1_Timer() : Show current time in panel 0 of the StatusBar myStatusbar.SetText(0, Format$(Now, "dddd, dd/mm/yyyy hh:nn:ss")) End Public Sub DirView1_Select() FileView1.Dir = DirView1.Current txbDirectory.Text = DirView1.Current txbFile.Clear() FileView1.Mode = Select.Multiple lblFile.Text = "File list: " txbFile.Clear End Public Sub FileView1_Click() Dim sElement As String txbFile.Clear txbFile.Text = "| " If FileView1.Mode = Select.Single Then txbFile.Text = DirView1.Current &/ FileView1.Current Else For Each sElement In FileView1.Selection '-- FileView1.Selection = Array with the selected files txbFile.Text &= sElement & " | " Next Endif End Public Sub btnFileSelectMode_Click() If btnFileSelectMode.Value = True Then '-- If True, then Select.Multiple is active btnFileSelectMode.Picture = Picture["Symbols/single.png"] btnFileSelectMode.Tooltip = "Switch to select mode 'Single'" FileView1.Mode = Select.Multiple lblFile.Text = "File list: " txbFile.Clear() myStatusbar.SetText(1, "Select-Mode: Select.Multiple") Else btnFileSelectMode.Picture = Picture["Symbols/multiple.png"] btnFileSelectMode.Tooltip = "Switch to Select mode 'Multiple'" FileView1.Mode = Select.Single lblFile.Text = "File path: " If FileView1.Selection.Count > 0 Then txbFile.Text = DirView1.Current &/ FileView1.Selection[0] Endif myStatusbar.SetText(1, "Select-Mode: Select.Single") Endif End Public Sub btnClose_Click() FMain.Close() End ' btnClose_Click() Public Sub Form_Close() myStatusBar.Delete() End
Chapter & Project