Skip to main content
A newer version of this page is available. .

Behaviors

  • 3 minutes to read

Attach a Behavior to target controls and components to template them in a specific manner. For instance, a Clock Behavior turns a LabelControl or a digital gauge into a clock.

Behaviors - Clock Behavior

Target controls do not necessarily have common ancestors, so Behaviors are implemented as standalone objects.

Attach a Behavior to a Control

Open the Visual Studio’s Toolbox window, locate the Behavior Manager component and drop it onto the form. Invoke the component smart tag and click “Edit Behaviors”.

Behaviors - Component Smarttag

Once you click the link, the Collection Editor dialog pops up. You can create new Behaviors and attach them to controls by setting their Target properties using this dialog.

Behaviors - Collection Editor

Most controls that support Behaviors display the “Add Behaviors…” link within their smart tags. Clicking this link automatically adds the Behavior Manager component and opens its Collection Editor dialog. However, you can create and modify Behaviors assigned to this control only.

Behaviors - Attach Behavior

Behaviors can also be attached in code using the Behavior Manager’s Attach method and utilizing lambda expressions to set the required Behavior options.


using DevExpress.Utils.Behaviors.Common;

behaviorManager1.Attach<OpenFolderBehavior>(beOpenFolder, behavior => {
    behavior.Properties.IconSize = FileIconSize.Small;
    behavior.Properties.InvalidPathImage = DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/close_16x16.png");
    behavior.Properties.ShowIcon = true;
});

Available Behaviors

The table below enumerates all supported Behaviors and controls to which Behaviors you can attach them. You can also submit Support Center tickets to request new Behaviors.

Behavior Name

Description

Target Controls

FileIconBehavior

Checks the display text of the target control and if this text is a path to an existing file or folder, adds its icon to the control.

TextEdit

ButtonEdit

LabelControl

FilePathBehavior

Same as FileIconBehavior. Additionally, if the target control allows end-users to edit display text at runtime, it also provides the auto-complete feature.

TextEdit

ButtonEdit

OpenFileBehavior

OpenFolderBehavior

Attach these behaviors to a ButtonEdit control to instantly transform it into an editor that allows end-users to choose a file or a folder from the local storage. The editor displays an icon and a caption of the selected file (folder).

ButtonEdit

PersistenceBehavior

This behavior can be attached to a form to restore its last known position and size at runtime.

XtraForm

Ribbon Form

Tabbed Form

controls that implement the ISupportXtraSerializer interface

SnapWindowBehavior

Turns standard and DevExpress forms into sticky windows that can snap to other windows and screen edges.

XtraForm

Ribbon Form

Tabbed Form

standard forms and their descendants

StubGlyphBehavior

With this behavior attached, items that have no custom icons display temporary fake images.

GridColumn

ImageComboBoxEdit

LayoutControlGroup

LayoutControlItem

XtraTabPage

TreeListColumn

ImageListBoxControl

ClockBehavior

A control with this behavior displays current system’s date and time. The behavior provides the ability to customize both date and time data portions separately.

LabelControl

BarStaticItem

DigitalGauge

KeyboardIndicatorBehavior

Indicates whether or not the specific system key (Caps Lock, Num Lock, Scroll Lock) is currently pressed.

LabelControl

BarStaticItem

BannerBehavior

Forces a PictureEdit control to cycle through a collection of images instead of constantly displaying the same one.

PictureEdit

DragAndDropBehavior

Adds support for drag-and-drop operations between controls.

ListBoxControl

GridControl (GridView)

TreeList

Magnifier Behavior

Allows users to pick colors from the screen using the Magnifier tool.

All ColorEdit descendants