windowsforms-devexpress-dot-xtragrid-dot-views-dot-bandedgrid-dot-gridband-41ba2c6c.md
Gets columns owned by the band.
Namespace : DevExpress.XtraGrid.Views.BandedGrid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[Browsable(false)]
[XtraSerializableProperty(XtraSerializationVisibility.NameCollection, true, true, true)]
[XtraSerializablePropertyId(3)]
public virtual GridBandColumnCollection Columns { get; }
<Browsable(False)>
<XtraSerializableProperty(XtraSerializationVisibility.NameCollection, True, True, True)>
<XtraSerializablePropertyId(3)>
Public Overridable ReadOnly Property Columns As GridBandColumnCollection
| Type | Description |
|---|---|
| GridBandColumnCollection |
A GridBandColumnCollection object that contains band columns.
|
Only bands located at the bottom of the bands hierarchy can have child columns. In other words, the Columns property of a band owning other bands returns an empty collection.
Use the Columns property to manage columns owned by a band. The GridBandColumnCollection object returned by this property enables you to add, delete and access individual columns. You can use the collection’s GridBandColumnCollection.Add or GridBandColumnCollection.Insert methods to add a column to the band (the column is first removed from its previous band and then added to the current one). The GridBandColumnCollection.Remove method can be used to remove the column from its current parent band. The column becomes invisible as a result.
Note
In Banded Grid Views, the column visual order within the parent band depends on the columns order within the Columns collection. Thus, you should move columns using the collection’s GridBandColumnCollection.MoveTo method to rearrange columns within the View.
The following example creates two bands and adds it to the root band’s Children collection:
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; }
}
}
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