GridBand 动态创建

using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.BandedGrid.ViewInfo;
using DevExpress.XtraGrid.Views.Base;

第二步:创建表头

GridBand band1 = new GridBand();

band1.Caption = "Band1";

parentBand.Children.Add(band1);

第三步:创建绑定列

DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandcolumn= this.advBandedGridView1.Columns.Add();

bandcolumn.FieldName="Dataset数据源对应的列名";

bandcolumn.Name="bandcolumn1";

bandcolumn.Visible = true;

第四步:绑定

band1.Columns.Add(bandcolumn);

这样就完成了动态的生成表头及绑定。

原文地址:https://www.cnblogs.com/linyijia/p/1869846.html