## wxFilePickerCtrl

This control allows the user to select a file. The generic implementation is a button which brings up a wxFileDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the file-chooser dialog. It is only available if `wxUSE_FILEPICKERCTRL` is set to 1 (the default).

Derived from

wxPickerBase
wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/filepicker.h>

Window styles

wxFLP_DEFAULT_STYLE | The default style: includes wxFLP_OPEN | wxFLP_FILE_MUST_EXIST and, under wxMSW only, wxFLP_USE_TEXTCTRL.
wxFLP_USE_TEXTCTRL | Creates a text control to the left of the picker button which is completely managed by the wxFilePickerCtrl and which can be used by the user to specify a path (see SetPath). The text control is automatically synchronized with button's value. Use functions defined in wxPickerBase to modify the text control.
wxFLP_OPEN | Creates a picker which allows the user to select a file to open.
wxFLP_SAVE | Creates a picker which allows the user to select a file to save.
wxFLP_OVERWRITE_PROMPT | Can be combined with wxFLP_SAVE only: ask confirmation to the user before selecting a file.
wxFLP_FILE_MUST_EXIST | Can be combined with wxFLP_OPEN only: the selected file must be an existing file.
wxFLP_CHANGE_DIR | Change current working directory on each user file selection change.

NB: the wxFD_MULTIPLE style of wxFileDialog is not supported!

Event handling

To process a file picker event, use these event handler macros to direct input to member functions that take a wxFileDirPickerEvent argument.

EVT_FILEPICKER_CHANGED(id, func) | The user changed the file selected in the control either using the button or using text control (see wxFLP_USE_TEXTCTRL; note that in this case the event is fired only if the user's input is valid, e.g. an existing file path if wxFLP_FILE_MUST_EXIST was given).

See also

wxFileDialog,
wxFileDirPickerEvent

Members

wxFilePickerCtrl::wxFilePickerCtrl
wxFilePickerCtrl::Create
wxFilePickerCtrl::GetPath
wxFilePickerCtrl::SetPath

### wxFilePickerCtrl::wxFilePickerCtrl

wxFilePickerCtrl(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message = "Select a file", const wxString& wildcard = "*.*", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxFLP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "filepickerctrl")

Initializes the object and calls Create with all the parameters.

### wxFilePickerCtrl::Create

bool Create(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message = "Select a file", const wxString& wildcard = "*.*", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxFLP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "filepickerctrl")

Parameters

parent

Parent window, must not be non-`NULL`.

id

The identifier for the control.

path

The initial file shown in the control. Must be a valid path to a file or the empty string.

message

The message shown to the user in the wxFileDialog shown by the control.

wildcard

A wildcard which defines user-selectable files (use the same syntax as for wxFileDialog's wildcards).

pos

Initial position.

size

Initial size.

style

The window style, see `wxFLP_*` flags.

validator

Validator which can be used for additional date checks.

name

Control name.

Return value

`true` if the control was successfully created or `false` if creation failed.

### wxFilePickerCtrl::GetPath

wxString GetPath() const

Returns the absolute path of the currently selected file.

### wxFilePickerCtrl::SetPath

void SetPath(const wxString &filename)

Sets the absolute path of the currently selected file. This must be a valid file if the `wxFLP_FILE_MUST_EXIST` style was given.