Banded Grid Views

https://docs.devexpress.com/WindowsForms/114637/controls-and-libraries/data-grid/views/banded-grid-views

Banded Grid Views

  • Jun 19, 2019
  • 5 min to read

 

Banded Grid View (BandedGridView) displays data in a tabular form and organizes columns into bands. Advanced Banded View (AdvBandedGridView) does the same and additionally supports complex layouts of data cells.

Demo: Banded Views

#Bands and Columns

BandedGridView and AdvBandedGridView Views feature bands - stripes that organize grid columns into categories.

 

Data Grid - Bands - Overview

Columns in banded Views are instances of the BandedGridColumn class and inherit most of their settings from the parent GridColumn class.

#Add, Remove, Reorder and Modify Bands

Run the Grid Designer and switch to the "Bands" tab. This tab has buttons to add and remove bands, and a property grid to modify band settings. You can also re-arrange bands by dragging them.

 

Data Grid - Bands - Drag Bands

In code, create GridBand objects and place them to the BandedGridView.Bands collection.

Related API

#Add Columns to Bands

At design time, drag a column and drop it below a band.

Data Grid - Bands - Drag Columns

In code, either access the band GridBand.Columns collection and call its "Add""AddRange" and "Insert" methods, or specify the BandedGridColumn.OwnerBand property for a column.


gridBand2.Columns.Add(colFreight);
//or
colFreight.OwnerBand = gridBand2;

Related API

#Multi-Level Bands

It is possible to stack bands below bands, forming a multi-level band hierarchy.

Data Grid - Bands - Multilevel

To do this at design time, drag and drop bands in the Grid Designer's "Bands" tab. In code, place child bands into parent bands' GridBand.Children collections. To retrieve a parent band, use the GridBand.ParentBand property.


//organize bands 2 and 3 under the first one
gridBand2.ParentBand.Children.Add(gridBand3);
//or

#Band Headers

Use the following API to modify band headers.

#Fixed Bands

Similarly to columns, you can anchor bands to left and right sides of a View. Such bands are called fixed and remain in place as end-users scroll through the View.

 

Related API

#Column Layout in Advanced Banded Views

In an Advanced Banded View, a single row can display vertically stacked cells that belong to different columns. The figure below is a screenshot of the Banded Views demo with eight columns stacked into four rows with the "Performance" band above them.

Data Grid - Bands - Columns in AdvBanded

At design time, you can arrange columns by dragging them directly on the form surface.

Related API


using DevExpress.XtraGrid.Views.BandedGrid;

// assigning columns to bands 
colHP.OwnerBand = bandPerfomancel;
colCyl.OwnerBand = bandPerfomancel;
colCapacity.OwnerBand = bandPerfomancel;
colGear.OwnerBand = bandPerfomancel;
colImage.OwnerBand = bandPicture;
// changing the columns layout within bands 
AdvBandedGridView View = colHP.View
view.SetColumnPosition(colHP, 0, 0);
view.SetColumnPosition(colCyl, 0, 1);
view.SetColumnPosition(colCapacity, 1, 0);
view.SetColumnPosition(colGear, 1, 1);
view.SetColumnPosition(colImage, 0, 0);
// forcing the Image column to stretch its header if needed 
colImage.AutoFillDown = true;

#End-User Customization

At runtime, end-users can drag-and-drop columns and bands to customize the layout as their needs dictate. It is also possible to hide and restore bands at runtime by calling the "Customization" dialog.

Data Grid - Bands - Customization

Related API

SEE ALSO

Get Started With Data Grid and Views

https://docs.devexpress.com/WindowsForms/113894/controls-and-libraries/data-grid/getting-started-with-data-grid-and-views

Example

The following example replaces the existing top level View with a BandedGridView, and adds a band and column to the View.


using DevExpress.XtraGrid.Views.BandedGrid;

//Dispose of the old view
gridControl1.MainView.Dispose();
//Create a Banded Grid View
BandedGridView bandedView = new BandedGridView(gridControl1);
gridControl1.MainView = bandedView;
//Add one band and one column to the view
GridBand band = bandedView.Bands.AddBand("General");
BandedGridColumn column = (BandedGridColumn)bandedView.Columns.AddField("CustomerID");
column.OwnerBand = band;
column.Visible = true;

#Layout of Columns and Bands (in Grid Views and Banded Grid Views)

After grid columns are created, you may want to customize the layout of columns (and bands in Banded Views) in a custom manner. This section describes basic customization capabilities available for Grid and Banded Grid View types at design time. All these actions can be replicated in code, if required, by adjusting corresponding View and column settings.

To learn about customizing other Views, refer to the following topics.

The GridViewBandedGridView and AdvBandedGridView support on-form design-time layout customization. You can re-order, resize and hide columns and bands using drag-and-drop.

 

The context menu, invoked on a column header click, allows you to sort and group data against a column, calculate the best column width and show the Column Chooser (Column/Band Chooser in Banded Views) - a floating panel that provides access to hidden columns (and bands in Banded Views). Hidden columns (and bands) can be restored from the Column/Band Chooser back to the View using drag-and-drop.

gridcolumn-contextmenu.png

Instead of these design-time actions, you can modify the corresponding settings of grid columns and bands in the VS Property Grid (GridColumn.VisibleIndexGridBand.VisibleIndexGridColumn.WidthGridColumn.SortOrderGridColumn.SortIndex, etc.).

For Banded Views (BandedGridView and AdvBandedGridView), use the Bands page of the data grid's Designer to add new bands and re-arrange bands and columns (you can also re-arrange bands and columns right on-the-form).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值