1)使用BandedGridView控件(此处演示BandedGridView控件包含8个列)
2)往BandedGridView控件里添加GridBand控件(此处演示添加了4个)
3)
///设置添加的GridBand控件的标题文本
this.gridBand1.Caption = "A";
this.gridBand2.Caption = "B";
this.gridBand3.Caption = "C";
this.gridBand4.Caption = "D";
4)
///位GridBand控件添加要包含的列,往GridBand控件里面塞BandedGridView控件的列
this.gridBand1.Columns.Add(this.bandedGridView1.Columns[0]);
this.gridBand1.Columns.Add(this.bandedGridView1.Columns[1]);
this.gridBand2.Columns.Add(this.bandedGridView1.Columns[2]);
this.gridBand2.Columns.Add(this.bandedGridView1.Columns[3]);
this.gridBand3.Columns.Add(this.bandedGridView1.Columns[4]);
this.gridBand3.Columns.Add(this.bandedGridView1.Columns[5]);
this.gridBand4.Columns.Add(this.bandedGridView1.Columns[6]);
this.gridBand4.Columns.Add(this.bandedGridView1.Columns[7]);
///循环对齐表头
for (int i = 0; i < this.bandedGridView1.Columns.Count; i++)
{
this.bandedGridView1.Columns[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//表头居中对齐
}
///循环对齐BandedGridView控件的GridBand控件 表头
for (int i = 0; i < this.bandedGridView1.Bands.Count; i++)
{
this.bandedGridView1.Bands[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//居中对齐
}
其它相关参考:
DevExpress GridControl使用经验总结
http://www.360doc.com/content/14/0429/15/10893884_373218734.shtml