Back to Devexpress

GridControl.Bands Property

wpf-devexpress-dot-xpf-dot-grid-dot-gridcontrol-dd407f46.md

latest4.1 KB
Original Source

GridControl.Bands Property

Gets a collection of the GridControl‘s bands.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public ObservableCollectionCore<GridControlBand> Bands { get; }
vb
Public ReadOnly Property Bands As ObservableCollectionCore(Of GridControlBand)

Property Value

TypeDescription
DevExpress.Xpf.Core.ObservableCollectionCore<GridControlBand>

A collection of the GridControl‘s bands.

|

Remarks

The GridControl stores its bands in the Bands collection. This collection’s methods allow you to add new and remove existing bands. The GridControlBand objects are individual bands. You can access bands by an index.

xaml
<dxg:GridControl.Bands>
    <dxg:GridControlBand Header="Customer">
        <dxg:GridColumn FieldName="Name"/>
    </dxg:GridControlBand>
    <dxg:GridControlBand Header="Information">
        <dxg:GridColumn FieldName="City"/>
        <dxg:GridColumn FieldName="Visits"/>
        <dxg:GridColumn FieldName="Birthday"/>
    </dxg:GridControlBand>
</dxg:GridControl.Bands>

View Example: Create a Banded View

Note

You cannot explicitly specify a band‘s width. The width of the GridControl‘s bands depends on the width of band columns.

The following code sample sorts the GridControl‘s data agains the specified band’s column:

csharp
public partial class MainWindow : Window {
    public MainWindow() {
        ...

        grid.SortBy(grid.Bands.Single(b => b.Header.ToString() == "Information").Columns.Single(c => c.FieldName == "Visits"));
    }
}
vb
Public Partial Class MainWindow
    Inherits Window

    Public Sub New()
        ...

        grid.SortBy(grid.Bands.Single(Function(b) b.Header.ToString() = "Information").Columns.Single(Function(c) c.FieldName = "Visits"))
    End Sub
End Class

Note

You cannot set the Bands and the GridControl.Columns properties at the same time.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Bands property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-create-filter-ui/CS/WpfApplication27/MainWindow.xaml#L41

xml
<dxg:GridControl x:Name="myGrid" Grid.Column="1" ItemsSource="{Binding Orders}" FilterCriteria="{Binding Path=FilterCriteria, ElementName=filteringBehavior}">
    <dxg:GridControl.Bands>
        <dxg:GridControlBand Header="Order" OverlayHeaderByChildren="True">

See Also

GridControl Class

GridControl Members

DevExpress.Xpf.Grid Namespace