Skip to main content

BandedGridColumn.OwnerBand Property

Gets or sets a column’s parent band.

Namespace: DevExpress.XtraGrid.Views.BandedGrid

Assembly: DevExpress.XtraGrid.v24.2.dll

Declaration

[Browsable(false)]
public virtual GridBand OwnerBand { get; set; }

Property Value

Type Description
GridBand

A GridBand object representing a band to which a column belongs.

Remarks

If the OwnerBand property value is null (Nothing in Visual Basic), the column is not displayed.

Assigning a band to the OwnerBand property moves the column from its current parent. If the assigned band can accept this column, it is added to its column collection. It is appended to the equivalent band row from where it previously resided. If the required row doesn’t exist, the column is added to the last band row available.

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