Skip to main content

XRControl.Controls Property

Gets the collection of XRControl objects or their descendants that are contained in this control.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v22.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

[Browsable(false)]
public virtual XRControlCollection Controls { get; }

Property Value

Type Description
XRControlCollection

An object of the XRControlCollection class representing the collection of contained controls.

Remarks

An XRControl object acts as a parent for any control contained within its collection. This collection is returned by its Controls property. Objects in this collection are considered to be child controls of the XRControl object. If a control can have child controls then its XRControl.CanHaveChildren property is equal to true.

Example

The following method aligns controls contained in an XRControl object. The controls are aligned with the topmost control. Access to the controls is provided via the XRControl.Controls property.

using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

public void AlignHorizontally(XRControl container) {

    // Make sure that the collection is not empty.
    if(container.Controls.Count > 0) {

        // Assign the Y-coordinate of the first control in the collection to a variable.
        int y = container.Controls[0].Top;

        // Find the Y-coordinate of the topmost control.
        foreach(XRControl control in container.Controls) 
            if(control.Top < y)
                y = control.Top;

        // Align the controls with the topmost control.
        foreach(XRControl control in container.Controls) 
            control.Location = new Point(control.Left, y);
    }
}
See Also