一佳一

记录像1+1一样简洁的代码

导航

GridBand 动态创建

Posted on 2010-11-05 13:06  一佳一  阅读(3054)  评论(0编辑  收藏  举报

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);

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