Back to Devexpress

GridBand.Children Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-bandedgrid-dot-gridband-f87f60c0.md

latest6.3 KB
Original Source

GridBand.Children Property

Gets a collection of child/nesting bands.

Namespace : DevExpress.XtraGrid.Views.BandedGrid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
[XtraSerializableProperty(true, true, true)]
[XtraSerializablePropertyId(3)]
public virtual GridBandCollection Children { get; }
vb
<Browsable(False)>
<XtraSerializableProperty(True, True, True)>
<XtraSerializablePropertyId(3)>
Public Overridable ReadOnly Property Children As GridBandCollection

Property Value

TypeDescription
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:

csharp
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; }
    }
}
vb
Imports DevExpress.XtraGrid.Views.BandedGrid
Imports System
Imports System.ComponentModel

Namespace DXApplication
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            gridControl1.DataSource = New BindingList(Of DataItem)() From {
                New DataItem() With {
                    .StringProperty = "Value A",
                    .BooleanProperty = True,
                    .IntegerProperty = 10
                },
                New DataItem() With {
                    .StringProperty = "Value B",
                    .BooleanProperty = True,
                    .IntegerProperty = 15
                },
                New DataItem() With {
                    .StringProperty = "Value C",
                    .BooleanProperty = False,
                    .IntegerProperty = 20
                }
            }
            AddHandler Me.Load, AddressOf Form1_Load
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Creates the first child band.
            Dim childBand1 As GridBand = 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.
            Dim childBand2 As GridBand = rootBand.Children.AddBand("Child Band 2")
            childBand2.Columns.Add(bandedGridView1.Columns("BooleanProperty"))
        End Sub
    End Class
    Public Class DataItem
        Public Property StringProperty() As String
        Public Property IntegerProperty() As Integer
        Public Property BooleanProperty() As Boolean
    End Class
End Namespace

See Also

HasChildren

ParentBand

RootBand

Banded Grid Views

GridBand Class

GridBand Members

DevExpress.XtraGrid.Views.BandedGrid Namespace