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

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.v20.2.dll

NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.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);
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the Controls property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also