xtd 1.0.0
Loading...
Searching...
No Matches
xtd::forms::open_file_dialog Class Referencefinal
Inheritance diagram for xtd::forms::open_file_dialog:
xtd::forms::file_dialog xtd::forms::common_dialog xtd::forms::component xtd::object

Definition

Displays a standard dialog box that prompts the user to open a file. This class cannot be inherited.

Header
#include <xtd/forms/open_file_dialog>
Namespace
xtd::forms
Library
xtd.forms
Appearance
Windows macOS Gnome
Light
Dark
Examples
The following code example demonstrates the use of open_file_dialog dialog.
#include <xtd/xtd>
class form1 : public form {
public:
form1() {
text("Open file dialog example");
controls().add(button1);
auto_scroll(true);
button1.location({10, 10});
button1.text("Open...");
button1.click += delegate_ {
auto dialog = open_file_dialog {};
dialog.file_name(io::path::get_file_name(file_name));
dialog.filter("Text Files (*.txt)|*.txt|All Files (*.*)|*.*");
if (dialog.show_sheet_dialog(*this) == forms::dialog_result::ok) {
file_name = dialog.file_name();
label1.text(string::format("File = {}", file_name));
}
};
label1.parent(*this);
label1.text("File = ");
label1.auto_size(true);
label1.location({10, 50});
}
private:
label label1;
string file_name;
};
auto main() -> int {
application::run(form1 {});
}
@ desktop
The logical Desktop rather than the physical file system location.
Definition environment.hpp:149
static auto get_folder_path(environment::special_folder folder) -> xtd::string
Gets the path to the system special folder that is identified by the specified enumeration.
Definition environment.hpp:615
virtual auto text() const noexcept -> const xtd::string &
Gets the text associated with this control.
virtual auto controls() noexcept -> control_collection &
Gets the collection of controls contained within the control.
virtual auto initial_directory() const noexcept -> const xtd::string &
Gets the initial directory displayed by the file dialog box.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Displays a standard dialog box that prompts the user to open a file. This class cannot be inherited.
Definition open_file_dialog.hpp:30
virtual auto auto_scroll() const noexcept -> bool
Gets a value indicating whether the container enables the user to scroll to any controls placed outsi...
static auto get_directory_name(const xtd::string &path) -> xtd::string
Returns the directory information for the specified path string.
static auto get_file_name(const xtd::string &path) -> xtd::string
Returns the file name and extension of the specified path string.
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:1018
xtd::forms::style_sheets::control label
The label data allows you to specify the box of a label control.
Definition label.hpp:25
xtd::forms::style_sheets::control button
The buttton data allows you to specify the box of a button control.
Definition button.hpp:25
@ ok
The dialog box return value is OK (usually sent from a button labeled OK).
Definition dialog_result.hpp:47
@ button1
The first button on the message box is the default button.
Definition message_dialog_default_button.hpp:24

Public Constructors

 open_file_dialog ()=default
 Initializes a new instance of the open_file_dialog class.

Public Properties

auto open_file () const noexcept -> std::ifstream
 Opens the file with read only permission selected by the user.
auto multiselect () const noexcept -> bool
 Gets a value indicating whether the dialog box allows multiple files to be selected.
auto multiselect (bool value) -> open_file_dialog &
 Sets a value indicating whether the dialog box allows multiple files to be selected.

Additional Inherited Members

xtd::event< common_dialog, xtd::forms::help_event_handlerhelp_request
 Occurs when the user clicks the Help button on a common dialog box.
xtd::event< common_dialog, xtd::forms::dialog_closed_event_handlerdialog_closed
 Occurs when the user close a common dialog box with dialog close button or other dialog buttons.
 file_dialog ()
 Initializes a new instance of the common_dialog class.
virtual auto add_extension () const noexcept -> bool
 Gets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension.
virtual auto add_extension (bool value) -> file_dialog &
 Sets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension.
virtual auto auto_upgrade_enabled () const noexcept -> bool
 Gets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista.
virtual auto auto_upgrade_enabled (bool value) -> file_dialog &
 Sets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista.
virtual auto check_file_exists () const noexcept -> bool
 Gets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist.
virtual auto check_file_exists (bool value) -> file_dialog &
 Sets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist.
virtual auto check_path_exists () const noexcept -> bool
 Gets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist.
virtual auto check_path_exists (bool value) -> file_dialog &
 Sets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist.
virtual auto default_ext () const noexcept -> const xtd::string &
 Gets the default file name extension.
virtual auto default_ext (const xtd::string &value) -> file_dialog &
 Sets the default file name extension.
virtual auto dereference_link () const noexcept -> bool
 Gets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk).
virtual auto dereference_link (bool value) -> file_dialog &
 Sets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk).
virtual auto file_name () const noexcept -> const xtd::string &
 Gets a string containing the file name selected in the file dialog box.
virtual auto file_name (const xtd::string &value) -> file_dialog &
 Sets a string containing the file name selected in the file dialog box.
virtual auto file_names () const noexcept -> xtd::array< xtd::string >
 Gets the file names of all selected files in the dialog box.
virtual auto filter () const noexcept -> const xtd::string &
 Gets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box.
virtual auto filter (const xtd::string &value) -> file_dialog &
 Sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box.
virtual auto filter_index () const noexcept -> xtd::usize
 Gets the index of the filter currently selected in the file dialog box.
virtual auto filter_index (xtd::usize value) -> file_dialog &
 Sets the index of the filter currently selected in the file dialog box.
virtual auto initial_directory () const noexcept -> const xtd::string &
 Gets the initial directory displayed by the file dialog box.
virtual auto initial_directory (const xtd::string &value) -> file_dialog &
 Sets the initial directory displayed by the file dialog box.
auto options () const noexcept -> xtd::usize
 Gets values to initialize the file_dialog.
virtual auto restore_directory () const noexcept -> bool
 Gets a value indicating whether the dialog box restores the directory to the previously selected directory before closing.
virtual auto restore_directory (bool value) -> file_dialog &
 Sets a value indicating whether the dialog box restores the directory to the previously selected directory before closing.
virtual auto show_help () const noexcept -> bool
 Gets a value indicating whether the Help button is displayed in the file dialog box.
virtual auto show_help (bool value) -> file_dialog &
 Sets a value indicating whether the Help button is displayed in the file dialog box.
virtual auto show_hidden_files () const noexcept -> bool
 Gets a value indicating whether hidden files are displayed in the file dialog box.
virtual auto show_hidden_files (bool value) -> file_dialog &
 Sets a value indicating whether hidden files are displayed in the file dialog box.
virtual auto show_preview () const noexcept -> bool
 Gets a value indicating whether preview file is displayed in the file dialog box.
virtual auto show_preview (bool value) -> file_dialog &
 Sets a value indicating whether preview file is displayed in the file dialog box.
virtual auto support_multi_dotted_extensions () const noexcept -> bool
 Gets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions.
virtual auto support_multi_dotted_extensions (bool value) -> file_dialog &
 Sets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions.
virtual auto title () const noexcept -> const xtd::string &
 Gets the file dialog box title.
virtual auto title (const xtd::string &value) -> file_dialog &
 Sets the file dialog box title.
virtual auto validate_names () const noexcept -> bool
 Gets a value indicating whether the dialog box accepts only valid file names.
virtual auto validate_names (bool value) -> file_dialog &
 Gets a value indicating whether the dialog box accepts only valid file names.
auto reset () noexcept -> void override
 Resets all properties to their default values.
auto to_string () const noexcept -> xtd::string override
 Provides a string version of this object.
 common_dialog ()
 Initializes a new instance of the common_dialog class.
auto dialog_result () const noexcept -> xtd::forms::dialog_result
 Gets async dialog_result result after dialog box is closing.
auto tag () const noexcept -> const xtd::any_object &
 Gets an object that contains data about the control.
auto tag (const xtd::any_object &value) -> common_dialog &
 Sets an object that contains data about the control.
auto show_dialog () -> xtd::forms::dialog_result
 Runs a common dialog box with a default owner.
auto show_dialog (const iwin32_window &owner) -> xtd::forms::dialog_result
 Runs a common dialog box with the specified owner.
auto show_sheet (const iwin32_window &owner) -> void
 Runs a common dialog box with the specified owner.
auto show_sheet_dialog (const iwin32_window &owner) -> xtd::forms::dialog_result
 Runs a common dialog box with the specified owner.
 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto equals (const object &obj) const noexcept -> bool
 Determines whether the specified object is equal to the current object.
virtual auto get_hash_code () const noexcept -> xtd::usize
 Serves as a hash function for a particular type.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.
auto run_dialog (xtd::intptr hwnd_owner) -> bool override
 Runs file dialog box.
auto run_sheet (xtd::intptr hwnd_owner) -> void override
 Runs file dialog box in sheet mode.
virtual auto on_dialog_closed (const xtd::forms::dialog_closed_event_args &e) -> void
 Raises the common_dialog::dialog_close event.
virtual auto on_help_request (xtd::forms::help_event_args &e) -> void
 Raises the common_dialog::help_request event.
auto set_dialog_result (xtd::forms::dialog_result value) -> void
 Sets async dialog_result result after dialog box is closing.
 component ()
 Initialises a new instance of the component class.
virtual auto can_raise_events () const noexcept -> bool
 Gets a value indicating whether the component can raise an event.
auto design_mode () const noexcept -> bool
 Gets a value that indicates whether the component is currently in design mode.

Constructor & Destructor Documentation

◆ open_file_dialog()

xtd::forms::open_file_dialog::open_file_dialog ( )
default

Initializes a new instance of the open_file_dialog class.

Member Function Documentation

◆ open_file()

auto xtd::forms::open_file_dialog::open_file ( ) const -> std::ifstream
nodiscardnoexcept

Opens the file with read only permission selected by the user.

Returns
The read only file selected by the user.

◆ multiselect() [1/2]

auto xtd::forms::open_file_dialog::multiselect ( ) const -> bool
nodiscardnoexcept

Gets a value indicating whether the dialog box allows multiple files to be selected.

Returns
true if the dialog box allows multiple files to be selected together or concurrently; otherwise, false. The default value is false.
Remarks
Use the file_names property to access the full list of selected file names.

◆ multiselect() [2/2]

auto xtd::forms::open_file_dialog::multiselect ( bool value) -> open_file_dialog &

Sets a value indicating whether the dialog box allows multiple files to be selected.

Parameters
valuetrue if the dialog box allows multiple files to be selected together or concurrently; otherwise, false. The default value is false.
Returns
Current open_file_dialog.
Remarks
Use the file_names property to access the full list of selected file names.

The documentation for this class was generated from the following file: