OpenFileDialog
From Xojo Documentation
Supported Platforms Project Types: Desktop Platforms: macOS, Windows, Linux |
Class (inherits from FolderItemDialog)
New in 2019r2
Creates a customizable Open-file dialog box. The non-customizable version of this dialog is displayed by the FolderItem.ShowOpenFileDialog function.
Properties | ||||||||||||
|
Methods | |||
|
Notes
Using the properties of the FolderItemDialog class, you can customize the following aspects of an open-file dialog box:
- Position (Left and Top properties)
- Default directory (Initial Directory property)
- Valid file types to show (Filter property)
- Text of the Validate and Cancel buttons (ActionButtonCaption and CancelButtonCaption properties)
- Text that appears in the Title bar of the dialog (Title property)
- Text that appears inside the dialog (PromptText property)
Examples
The following code opens a customizable open-file dialog box and presents the Documents or Home directory in the file browser. Only MIF files are listed. The file type passed to the Filter parameter was previously defined in a File Type Set called "TextTypes" in the File Type Sets Editor or via the FileType class.
Var dlg As OpenFileDialog
Var f As FolderItem
dlg = New OpenFileDialog
#If Not TargetLinux Then
dlg.InitialFolder = SpecialFolder.Documents
#Else //open Home directory on linux
dlg.InitialFolder = SpecialFolder.Home
#Endif
dlg.Title = "Select a Text file"
dlg.Filter = FileTypes1.Text // "text/plain" file type defined in FileTypes1 set
f = dlg.ShowModal
If f <> Nil Then
//proceed normally
Else
//User Cancelled
End If
Var f As FolderItem
dlg = New OpenFileDialog
#If Not TargetLinux Then
dlg.InitialFolder = SpecialFolder.Documents
#Else //open Home directory on linux
dlg.InitialFolder = SpecialFolder.Home
#Endif
dlg.Title = "Select a Text file"
dlg.Filter = FileTypes1.Text // "text/plain" file type defined in FileTypes1 set
f = dlg.ShowModal
If f <> Nil Then
//proceed normally
Else
//User Cancelled
End If
See Also
FileType, FolderItem, FolderItemDialog, SaveFileDialog, SelectFolderDialog classes; GetOpenFolderItem function.