IXtraResizableControl Interface

Defines an interface a control that can be implemented to provide layout information to a Layout Control.

Namespace: DevExpress.Utils.Controls

Assembly: DevExpress.Utils.v20.1.dll

Declaration

public interface IXtraResizableControl
Public Interface IXtraResizableControl

Remarks

The Layout Control is the control that provides advanced capabilities to create, customize and maintain a consistent layout of controls within a form. It maintains consistent control layouts, supports layout customization, the automatic control resizing feature, etc.

When a control is added to a Layout Control, a layout item is created that displays this control. The layout item can also display a label next to the control. A control can implement the IXtraResizableControl interface to provide layout information used to initialize the corresponding layout item's specific settings. This includes the control's default size constraints and whether the layout item's label should be visible by default.

Default size constraints are supplied via the IXtraResizableControl.MinSize and IXtraResizableControl.MaxSize properties. If the default maximum size constraint is additionally customized for a control instance via its MaximumSize property, the actual default maximum size constraint will be calculated according to the OptionsView.ControlDefaultMaxSizeCalcMode option.

The default visibility of the layout item's label is specified by the IXtraResizableControl.IsCaptionVisible property. This property's value is used to initialize the BaseLayoutItem.TextVisible property. It's possible to change the BaseLayoutItem.TextVisible after the layout item has been created.

Most DevExpress editors provide layout information via the IXtraResizableControl interface. You can implement this interface for a custom control to allow it to communicate with the Layout Control.

Examples

The following example demonstrates a button control (the SimpleButton control's descendant) implementing the IXtraResizableControl interface. Size constraints retrieved via the IXtraResizableControl.MaxSize and IXtraResizableControl.MinSize properties prevent the button from being resized. The button's maximum and minimum sizes are set to a value of an inherited SizeableMinSize property. This property return the minimum size required to display the text in its entirety. When the button's text changes, the SizeableMinSize property is recalculated automatically, and it's only required to fire the IXtraResizableControl.Changed event to notify subscribers of the changes.

Note that the SimpleButton control already implements the IXtraResizableControl interface. So this example is only given for demonstration purposes.

using DevExpress.XtraEditors;
using DevExpress.Utils.Controls;

public class MySimpleButton : SimpleButton, IXtraResizableControl {
    bool IXtraResizableControl.IsCaptionVisible { get { return false; } }
    Size IXtraResizableControl.MinSize { get { return SizeableMinSize; } }
    Size IXtraResizableControl.MaxSize { get { return SizeableMinSize; } }
    private static readonly object layoutInfoChanged = new object();      
    event EventHandler IXtraResizableControl.Changed {
        add { Events.AddHandler(layoutInfoChanged, value); }
        remove { Events.RemoveHandler(layoutInfoChanged, value); }
    }        
    protected void RaiseChanged() {
        EventHandler changed = (EventHandler)Events[layoutInfoChanged];
        if (changed == null) return;
        changed(this, EventArgs.Empty);
    }
    public override string Text {
        get {
            return base.Text;
        }
        set {
            base.Text = value;
            RaiseChanged();
        }
    }
}
See Also