GridBand Class

Represents an individual band.

Namespace: DevExpress.XtraGrid.Views.BandedGrid

Assembly: DevExpress.XtraGrid.v20.1.dll


public class GridBand :
Public Class GridBand
    Inherits Component
    Implements IAppearanceOwner,


Banded Grid Views and Advanced Banded Grid Views allow you to arrange columns into bands. Visually, bands are represented by their headers displayed over headers of the columns belonging to the band. Note that as well as arranging columns into logical groups, band headers can be dragged at runtime to rearrange bands or hide them, etc. Thus the layout and visibility of several columns can be controlled at once.

Individual bands are represented by GridBand objects. Note that banded Views allow you to arrange bands into a tree. Thus, band objects provide the GridBand.Children property that contains the band's child band collection. Bands displayed at the root View level reside within the View's BandedGridView.Bands collection. Note that columns can belong only to bands residing at the bottom hierarchy levels. To assign a column to a band you need to add the desired column to the band's GridBand.Columns collection. Please refer to the Banded Grid Views and Rows topics for details.

Band objects are Component descendants. This enables you to access bands in code directly by their names.

Please refer to the Band Header and Banded Grid Views topics for additional information on bands.


This example shows how to create a GridControl, while presenting its underlying data using a banded grid format (BandedGridView). The example creates three bands (Main, Address and Phone), adds columns to the bands and customizes the background color for the third band and its columns.


using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.BandedGrid;

GridControl gridControl1 = new GridControl();
gridControl1.Parent = this;
gridControl1.Dock = DockStyle.Fill;

BandedGridView bandedGridView1 = new BandedGridView(gridControl1);
GridBand gridBandMain = new GridBand();
GridBand gridBandAddress = new GridBand();
GridBand gridBandPhone = new GridBand();
BandedGridColumn colCity = new BandedGridColumn();
BandedGridColumn colCompanyName = new BandedGridColumn();
BandedGridColumn colContactName = new BandedGridColumn();
BandedGridColumn colCountry = new BandedGridColumn();
BandedGridColumn colPhone = new BandedGridColumn();
BandedGridColumn colFax = new BandedGridColumn();

gridControl1.DataSource = this.customersBindingSource;
gridControl1.MainView = bandedGridView1;

bandedGridView1.Bands.AddRange(new GridBand[] {gridBandMain,gridBandAddress,gridBandPhone});
bandedGridView1.Columns.AddRange(new BandedGridColumn[] {colCompanyName,colContactName,colCity,colCountry,colPhone,colFax});

colCompanyName.FieldName = "CompanyName";
colCompanyName.Visible = true;
colCompanyName.Width = 94;

colContactName.FieldName = "ContactName";
colContactName.Visible = true;
colContactName.Width = 74;

colCountry.FieldName = "Country";
colCountry.Visible = true;
colCountry.Width = 67;

colCity.FieldName = "City";
colCity.Visible = true;
colCity.Width = 57;

colPhone.AppearanceCell.BackColor = System.Drawing.Color.PowderBlue;
colPhone.AppearanceCell.Options.UseBackColor = true;
colPhone.AppearanceHeader.BackColor = System.Drawing.Color.PowderBlue;
colPhone.AppearanceHeader.Options.UseBackColor = true;
colPhone.FieldName = "Phone";
colPhone.Visible = true;
colPhone.Width = 81;

colFax.AppearanceCell.BackColor = System.Drawing.Color.PowderBlue;
colFax.AppearanceCell.Options.UseBackColor = true;
colFax.AppearanceHeader.BackColor = System.Drawing.Color.PowderBlue;
colFax.AppearanceHeader.Options.UseBackColor = true;
colFax.FieldName = "Fax";
colFax.Visible = true;
colFax.Width = 84;

gridBandMain.Caption = "Main";
gridBandMain.VisibleIndex = 0;
gridBandMain.Width = 168;

gridBandAddress.Caption = "Address";
gridBandAddress.VisibleIndex = 1;
gridBandAddress.Width = 124;

gridBandPhone.AppearanceHeader.BackColor = System.Drawing.Color.LightBlue;
gridBandPhone.AppearanceHeader.Options.UseBackColor = true;
gridBandPhone.Caption = "Phone";
gridBandPhone.VisibleIndex = 2;
gridBandPhone.Width = 165;

bandedGridView1.OptionsCustomization.AllowChangeColumnParent = false;


See Also