File and Folder Browser Behaviors

  • 3 minutes to read

This document gathers multiple similar behaviors that solve various tasks related to browsing and selecting files and folders.

Note that each behavior inherits the preceding behavior's features on this list. Do not attach, for instance, a File Path Behavior to ButtonEdit if this editor already has the Open File Behavior attached.

File Icon Behavior

This behavior checks the displayed text of a target control and if this text is a path to an existing file or folder, adds its icon to the control. The following figure illustrates multiple label controls with this behavior attached to them.

Behaviors - FileIcon Behavior

Supported controls

Behavior options

  • ShowIcon - enables or disables the behavior.
  • IconSize - allows you to select the required size for file (folder) images: small, medium, large or extra large.

    Behaviors - FileIcon Sizes

    The default height of text box editors equals 20 pixels, which allows them to display only small icons. To display icons of other sizes, turn the RepositoryItem.AutoHeight property off and increase the editor's height by using the Size property.

    Behaviors - Custom Editor Height

  • InvalidPathImage - an icon that will be displayed when the target control does not display a valid file (folder) path. The assigned image is shown as is and does not scale in accordance to the IconSize setting.

    Behaviors - Invalid Path Image

File Path Behavior

Provides an auto-complete feature for the editor this behavior is attached to. Using this feature end-users can quickly enter file and/folder paths. Once a valid path is entered, its icon is displayed next to the editor's text.

Behaviors - File Path Behavior

To navigate through proposed auto-complete options, end-users can press Tab.

Supported controls

Behavior options

  • IconSize, InvalidPathImage - same as for the File Icon Behavior.
  • Mode - specifies whether the auto-complete feature proposes only folder paths, only file paths or both of them.
  • Filter - allows you to narrow auto-complete hints to a specific folder or file. For example, if this property is set to "Windows\Globalization\Time Zone", browsing the folder hierarchy on a system disc drive will instantly bring end-users to this folder.

Open File and Open Folder Behaviors

These behaviors instantly turn your editor into a file or a folder selector. The editor button invokes a dialog that allows you to select a file or a folder, depending on which behavior you have attached. The path and the icon of the object selected in this dialog are then shown by the editor.

Behaviors - Folder Browser

Supported controls

Behavior options

  • ShowIcon, IconSize, InvalidPathImage - same as for the File Icon Behavior.
  • DialogStyle - allows you to choose the dialog type and style:

    • Standard - the target control invokes default Visual Studio FolderBrowser dialogs;
    • Skinnable - the target control invokes skinnable DevExpress dialogs;
    • SkinnableWide and SkinnableCompact - these values are available for the Open Folder behavior only and allow you to choose between the "Wide" and "Compact" dialog styles (see the XtraFolderBrowserDialog.DialogStyle property);