This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
/
XtraReport1.vb
50 lines (43 loc) · 2.08 KB
/
XtraReport1.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
Imports System
Imports System.Drawing
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
Namespace WindowsApplication1
Public Partial Class XtraReport1
Inherits XtraReport
Public Sub New()
InitializeComponent()
AddHandler PrintingSystem.AfterMarginsChange, New MarginsChangeEventHandler(AddressOf PrintingSystem_AfterMarginsChange)
AddHandler PrintingSystem.PageSettingsChanged, New EventHandler(AddressOf PrintingSystem_PageSettingsChanged)
End Sub
Private Sub PrintingSystem_PageSettingsChanged(ByVal sender As Object, ByVal e As EventArgs)
ChangeReportSettings(sender)
End Sub
Private Sub PrintingSystem_AfterMarginsChange(ByVal sender As Object, ByVal e As MarginsChangeEventArgs)
ChangeReportSettings(sender)
End Sub
Private Sub ChangeReportSettings(ByVal sender As Object)
Dim ps As PrintingSystemBase = TryCast(sender, PrintingSystemBase)
Dim isLocationChanged As Boolean = False
Dim newPageWidth As Integer = ps.PageBounds.Width - ps.PageMargins.Left - ps.PageMargins.Right
Dim currentPageWidth As Integer = PageWidth - Margins.Left - Margins.Right
Dim shift As Integer = currentPageWidth - newPageWidth
For Each _band As Band In Bands
For Each _control As XRControl In _band.Controls
isLocationChanged = True
_control.Location = New Point(_control.Location.X - shift, _control.Location.Y)
Next
Next
If isLocationChanged = True Then
Margins.Top = ps.PageMargins.Top
Margins.Bottom = ps.PageMargins.Bottom
Margins.Left = ps.PageMargins.Left
Margins.Right = ps.PageMargins.Right
PaperKind = ps.PageSettings.PaperKind
PaperName = ps.PageSettings.PaperName
Landscape = ps.PageSettings.Landscape
CreateDocument()
End If
End Sub
End Class
End Namespace