实现XtraGrid的复杂表头(中文斜线分类) (学习)

http://www.cnblogs.com/spymaster/archive/2007/10/30/942793.html

场景:
      需要实现中文样式的复杂表头,如带斜线等。
解决方法:
      1、使用XtraGrid中的BandedGridView视图,并在Designer界面中,添加分组表头,进行布局处理。
      2、在CustomDrawBandHeader 事件中加入如下代码:
        

 1实现XtraGrid的复杂表头(中文斜线分类) (学习)if (e.Band.Caption == "")
 2实现XtraGrid的复杂表头(中文斜线分类) (学习)实现XtraGrid的复杂表头(中文斜线分类) (学习)            实现XtraGrid的复杂表头(中文斜线分类) (学习){
 3实现XtraGrid的复杂表头(中文斜线分类) (学习)                e.Handled = true;
 4实现XtraGrid的复杂表头(中文斜线分类) (学习)                e.Painter.DrawObject(e.Info);
 5实现XtraGrid的复杂表头(中文斜线分类) (学习)
 6实现XtraGrid的复杂表头(中文斜线分类) (学习)                Rectangle r = e.Bounds;
 7实现XtraGrid的复杂表头(中文斜线分类) (学习)                Pen pen = Pens.Gray;
 8实现XtraGrid的复杂表头(中文斜线分类) (学习)                e.Graphics.DrawLine(pen,new Point(r.X,r.Y),new Point(r.X+r.Width--,r.Y+r.Height-2));
 9实现XtraGrid的复杂表头(中文斜线分类) (学习)
10实现XtraGrid的复杂表头(中文斜线分类) (学习)                pen = Pens.Black;
11实现XtraGrid的复杂表头(中文斜线分类) (学习)                Font font = new Font("宋体",12,FontStyle.Bold);
12实现XtraGrid的复杂表头(中文斜线分类) (学习)                Brush brush = Brushes.Black;
13实现XtraGrid的复杂表头(中文斜线分类) (学习)                e.Graphics.DrawString("项目",font,brush,new PointF(r.X+110,r.Y+10));
14实现XtraGrid的复杂表头(中文斜线分类) (学习)                e.Graphics.DrawString("航班", font, brush, new PointF(r.X + 25, r.Y + 20));
15实现XtraGrid的复杂表头(中文斜线分类) (学习)            }

最终实现效果:实现XtraGrid的复杂表头(中文斜线分类) (学习)

转载于:https://www.cnblogs.com/forrestsun/articles/1832856.html