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

Layout Support For Third Party Controls

  • 2 minutes to read

All the information that the Layout Control should “know” about a control is its size constraints (minimum and maximum sizes) and whether to display a label for it initially (e.g. labels are by default visible for text editors and aren’t visible for buttons).

By now, the Layout Control “knows” about certain control types. These include most of the standard Windows Forms controls and the controls from the DevExpress XtraEditors Library. To register other controls, you can use one of the following options:

  • Support the IXtraResizableControl interface in the required control. This interface’s declaration is shown below. The IsCaptionVisible property specifies whether a label is displayed initially. The other two properties specify the default maximum and minimum sizes.

    
    public interface IXtraResizableControl {
       Size MinSize { get; }
       Size MaxSize { get; }
       event EventHandler Changed;
       bool IsCaptionVisible { get; }
    }
    

    You can implement the Changed event so that the control’s size constraints may respond to changes made to the control (e.g. its font size). But this option requires that you change a control’s source code or create its descendant. It can be used, for instance, to extend the controls from the XtraEditors Library.

  • Use the LayoutControl.ConstraintsManager.RegisterControlConstraints method. In addition to the control type, it accepts the same parameters that are required by the above interface - label visibility and size constraints. When using multiple Layout Controls within an application, this method must be called for each Layout Control.

    
    public void RegisterControlConstraints(Type type, Size minSize, Size maxSize, bool IsCaptionVisible);
    

    Standard Windows Forms controls are registered using this option.

 

Note

If the Layout Control doesn’t “know” a control, the label is visible by default.