xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-717d8034.md
Gets the collection of XRControl objects or their descendants that are contained in this control.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[Browsable(false)]
public virtual XRControlCollection Controls { get; }
<Browsable(False)>
Public Overridable ReadOnly Property Controls As XRControlCollection
| Type | Description |
|---|---|
| XRControlCollection |
An object of the XRControlCollection class representing the collection of contained controls.
|
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.
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);
}
}
Imports System.Drawing
Imports DevExpress.XtraReports.UI
' ...
Public Sub AlignHorizontally(ByRef container As XRControl)
' Make sure that the collection is not empty.
If container.Controls.Count > 0 Then
' Assign the Y-coordinate of the first control in the collection to a variable.
Dim y As Integer = container.Controls(0).Top
Dim control As XRControl
' Find the Y-coordinate of the topmost control.
For Each control In container.Controls
If (control.Top < y) Then
y = control.Top
End If
Next
' Align the controls with the topmost control.
For Each control In container.Controls
control.Location = New Point(control.Left, y)
Next
End If
End Sub
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.
reporting-winforms-create-hierarchical-report-from-flat-table/CS/TreeViewReport/ChildReport.cs#L30
foreach(Band band in report.Bands)
foreach(XRControl control in band.Controls) {
if(control is XRTable)
};
var chart = report.Bands[0].Controls[0] as XRChart;
chart.Parameters.Add(new XRControlParameter("chartCategory", report.Parameters[0]));
reporting-winforms-create-hierarchical-report-from-flat-table/VB/TreeViewReport/ChildReport.vb#L31
For Each band As Band In report.Bands
For Each control As XRControl In band.Controls
If TypeOf control Is XRTable Then TryCast(control, XRTable).WidthF = subreport.SizeF.Width
See Also