Skip to main content

HierarchyPrintOptions.Indent Property

Specifies the child level node offset, in report units.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public float Indent { get; set; }

Property Value

Type Description
Single

The child level node offset, in report units.

Property Paths

You can access this nested property as listed below:

Object Type Path to Indent
DetailBand

Remarks

The following code creates the Detail band for the hierarchical report:

using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.Utils.Svg;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
// ...
            DetailBand detailBand = new DetailBand() {
                Name = "Detail",
                HeightF = 25,
                EvenStyleName = "EvenStyle",
                Padding = new PaddingInfo(5, 5, 0, 0),
                Font = new Font("Tahoma", 9f),
            };
            // Print root level nodes in bold
            detailBand.ExpressionBindings.Add(new ExpressionBinding("Font.Bold", "[DataSource.CurrentRowHierarchyLevel] == 0"));
            // Sort data on each hierarchy level by the Region field
            detailBand.SortFields.Add(new GroupField("Region", XRColumnSortOrder.Ascending));
            // Specify Id-ParentID related fields
            detailBand.HierarchyPrintOptions.KeyFieldName = "RegionID";
            detailBand.HierarchyPrintOptions.ParentFieldName = "ParentRegionID";
            // Specify the child node offset
            detailBand.HierarchyPrintOptions.Indent = 25;

            // Add an XRCheckBox control as the DetailBand's drill-down control to allow end users to collapse and expand tree nodes
            XRCheckBox expandButton = new XRCheckBox() {
                Name = "DrillDownCheckBox",
                BoundsF = new RectangleF(0, 0, 25, 25),
            };
            expandButton.ExpressionBindings.Add(new ExpressionBinding("Checked", "[ReportItems].[" + detailBand.Name + "].[DrillDownExpanded]"));
            SvgImage checkedSvg = SvgImage.FromResources("CreateHierarchicalReportInCode.Expanded.svg", typeof(ReportCreator).Assembly);
            SvgImage uncheckedSvg = SvgImage.FromResources("CreateHierarchicalReportInCode.Collapsed.svg", typeof(ReportCreator).Assembly);
            expandButton.GlyphOptions.Alignment = HorzAlignment.Center;
            expandButton.GlyphOptions.Size = new SizeF(16, 16);
            expandButton.GlyphOptions.CustomGlyphs[CheckBoxState.Checked] = new ImageSource(checkedSvg);
            expandButton.GlyphOptions.CustomGlyphs[CheckBoxState.Unchecked] = new ImageSource(uncheckedSvg);
            detailBand.DrillDownControl = expandButton;
            detailBand.DrillDownExpanded = false;

            XRLabel regionLabel = new XRLabel() {
                Name = "RegionLabel",
                BoundsF = new RectangleF(25, 0, 450, 25),
                TextAlignment = TextAlignment.MiddleLeft,
                // Anchor the label to both the left and right edges of the DetailBand so that it fits the page's width
                AnchorHorizontal = HorizontalAnchorStyles.Both
            };
            regionLabel.ExpressionBindings.Add(new ExpressionBinding("Text", "[Region]"));
            XRLabel AreaLabel = new XRLabel() {
                Name = "AreaLabel",
                TextFormatString = "{0:N0}",
                BoundsF = new RectangleF(475, 0, 175, 25),
                TextAlignment = TextAlignment.MiddleRight,
                // Anchor the label to the right edge of the DetailBand
                AnchorHorizontal = HorizontalAnchorStyles.Right
            };
            AreaLabel.ExpressionBindings.Add(new ExpressionBinding("Text", "[Area]"));
            detailBand.Controls.AddRange(new XRControl[] { expandButton, regionLabel, AreaLabel });
            return detailBand;
        }
    }

View Example: How to Create a Hierarchical Report in Code

See Also