xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-e809e29c.md
Specifies the parent object that contains the current control.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[Browsable(false)]
public virtual XRControl Parent { get; set; }
<Browsable(False)>
Public Overridable Property Parent As XRControl
| Type | Description |
|---|---|
| XRControl |
The current control’s parent.
|
This property returns a report, band or report control that contains the current control. You can then customize settings of the parent and its child controls. To check whether the parent contains child controls, use the XRControl.CanHaveChildren property. Use the XRControl.Controls property to get the collection of child controls.
using System.Drawing;
using DevExpress.XtraReports.UI;
//...
void OnTableCellBeforePrint(object sender, System.ComponentModel.EventArgs e) {
var tableCell = sender as XRTableCell;
// Get the parent control for the table cell.
var row = tableCell.Parent;
// Get the parent control for the table row.
var table = row.Parent;
// Specify the foreground color for even table rows.
if((table.Controls.IndexOf(row) % 2) == 0) {
tableCell.ForeColor = Color.Red;
}
}
Imports System.Drawing
Imports DevExpress.XtraReports.UI
'...
Private Sub OnTableCellBeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.EventArgs)
Dim tableCell = TryCast(sender, XRTableCell)
' Get the parent control for the table cell.
Dim row = tableCell.Parent
' Get the parent control for the table row.
Dim table = row.Parent
' Specify the foreground color for even table rows.
If (table.Controls.IndexOf(row) Mod 2) = 0 Then
tableCell.ForeColor = Color.Red
End If
End Sub
See Also