Skip to main content

GridBand.Children Property

Gets a collection of child/nesting bands.

Namespace: DevExpress.XtraGrid.Views.BandedGrid

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[Browsable(false)]
[XtraSerializableProperty(true, true, true)]
[XtraSerializablePropertyId(3)]
public virtual GridBandCollection Children { get; }

Property Value

Type Description
GridBandCollection

A GridBandCollection object that contains child bands.

Remarks

Use the band’s Children property to add, delete, and access individual child bands. Note that you should first customize bands at the View’s root (top) band level. Use the BandedGridView.Bands property to access root/top bands.

The GridBand.HasChildren property allows you to determine whether the band has child child bands.

Example: Create Child/Nesting Bands

The following example creates two bands and adds it to the root band’s Children collection:

WinForms Banded Grid View with Nested Bands, DevExpress

using DevExpress.XtraGrid.Views.BandedGrid;
using System;
using System.ComponentModel;

namespace DXApplication {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            InitializeComponent();
            gridControl1.DataSource = new BindingList<DataItem>() {
                new DataItem(){ StringProperty = "Value A", BooleanProperty = true, IntegerProperty = 10 },
                new DataItem(){ StringProperty = "Value B", BooleanProperty = true, IntegerProperty = 15 },
                new DataItem(){ StringProperty = "Value C", BooleanProperty = false, IntegerProperty = 20 },
            };
            this.Load += Form1_Load;
        }

        void Form1_Load(object sender, EventArgs e) {
            // Creates the first child band.
            GridBand childBand1 = rootBand.Children.AddBand("Child Band 1");
            // Adds the 'StringProperty' column to the first child band using the column's OwnerBand property.
            bandedGridView1.Columns["StringProperty"].OwnerBand = childBand1;
            // Adds the 'IntegerProperty' column to the first child band using the band.Columns.Add() method.
            childBand1.Columns.Add(bandedGridView1.Columns["IntegerProperty"]);

            // Creates the second child band.
            GridBand childBand2 = rootBand.Children.AddBand("Child Band 2");
            childBand2.Columns.Add(bandedGridView1.Columns["BooleanProperty"]);
        }
    }
    public class DataItem {
        public string StringProperty { get; set; }
        public int IntegerProperty{ get; set; }
        public bool BooleanProperty { get; set; }
    }
}
See Also