-
Notifications
You must be signed in to change notification settings - Fork 1
/
TableReport.vb
51 lines (43 loc) · 1.54 KB
/
TableReport.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Imports System.Drawing
Imports System.Drawing.Printing
Imports DevExpress.XtraReports.UI
' ...
Namespace XRTable_RuntimeCreation
Partial Public Class TableReport
Inherits XtraReport
Public Sub New()
InitializeComponent()
End Sub
Private Sub XtraReport1_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.BeforePrint
Me.Detail.Controls.Add(CreateXRTable())
End Sub
Public Function CreateXRTable() As XRTable
Dim cellsInRow As Integer = 3
Dim rowsCount As Integer = 3
Dim rowHeight As Single = 25F
Dim table As New XRTable()
table.Borders = DevExpress.XtraPrinting.BorderSide.All
table.BeginInit()
For i As Integer = 0 To rowsCount - 1
Dim row As New XRTableRow()
row.HeightF = rowHeight
For j As Integer = 0 To cellsInRow - 1
Dim cell As New XRTableCell()
cell.Text = String.Format("Row: {0}; Column:{1}", i, j)
row.Cells.Add(cell)
Next j
table.Rows.Add(row)
Next i
AddHandler table.BeforePrint, AddressOf table_BeforePrint
table.AdjustSize()
table.EndInit()
Return table
End Function
' The following code makes the table span to the entire page width.
Private Sub table_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
Dim table As XRTable = (DirectCast(sender, XRTable))
table.LocationF = New DevExpress.Utils.PointFloat(0F, 0F)
table.WidthF = Me.PageWidth - Me.Margins.Left - Me.Margins.Right
End Sub
End Class
End Namespace