开始使用Reports for WinForms > 打印和预览功能入门 > C1PrintDocument创建页眉 |
下面的内容描述了如何创建一个由三部分构成的页眉,并且给页眉添加背景色
创建由3部分组成的页眉
本文展示了如何创建一个分为三列的页眉。本文的关键点如下:
下面的详细步骤展示了如何创建一个由三部分构成的页眉。
Visual Basic
Visual Basic |
拷贝代码
|
---|---|
Me.C1PrintDocument1.StartDoc() Dim theader As New C1.C1Preview.RenderTable(Me.C1PrintDocument1) |
C#
C# |
拷贝代码
|
---|---|
this.c1PrintDocument1.StartDoc(); C1.C1Preview.RenderTable theader = new C1.C1Preview.RenderTable(this.c1PrintDocument1); |
Visual Basic
Visual Basic |
拷贝代码
|
---|---|
' Set up alignment for the parts of the header. theader.Cells(0, 0).Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Left theader.Cells(0, 1).Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Center theader.Cells(0, 2).Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Right theader.CellStyle.Font = New Font("Arial", 14) |
C#
C# |
拷贝代码
|
---|---|
// Set up alignment for the columns of the header. theader.Cells[0, 0].Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Left; theader.Cells[0, 1].Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Center; theader.Cells[0, 2].Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Right; theader.CellStyle.Font = new Font("Arial", 14); |
Visual Basic
Visual Basic |
拷贝代码
|
---|---|
theader.Cells(0, 0).Text = "Left part" theader.Cells(0, 1).Text = "Center part" theader.Cells(0, 2).Text = "Right part" Me.C1PrintDocument1.RenderBlock(theader) Me.C1PrintDocument1.EndDoc() |
C#
C# |
拷贝代码
|
---|---|
theader.Cells[0, 0].Text = "Left part"; theader.Cells[0, 1].Text = "Center part"; theader.Cells[0, 2].Text = "Right part"; this.c1PrintDocument1.RenderBlock(theader); this.c1PrintDocument1.EndDoc(); |
程序运行时,你新建的由三部分构成的页眉会看起来跟下面图中的相似
当设置了背景颜色(Gold)后,页眉会看起来跟下面图中的相似