This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
Form1.vb
72 lines (58 loc) · 1.94 KB
/
Form1.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.UserDesigner
' ...
Namespace EUD_NewReport
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
Dim form As New XRDesignFormEx()
Dim panel As XRDesignPanel = form.DesignPanel
panel.AddCommandHandler(New NewReportCommandHandler(panel))
AddHandler form.Load, AddressOf form_Load
form.ShowDialog()
End Sub
Private Sub form_Load(ByVal sender As Object, ByVal e As EventArgs)
DirectCast(sender, XRDesignFormEx).DesignPanel.ExecCommand(ReportCommand.NewReport)
End Sub
Public Class NewReportCommandHandler
Implements ICommandHandler
Private panel As XRDesignPanel
Private chooser As ReportChooser
Public Sub New(ByVal panel As XRDesignPanel)
Me.panel = panel
Me.chooser = New ReportChooser()
End Sub
Public Function CanHandleCommand(ByVal command As ReportCommand, ByRef useNextHandler As Boolean) As Boolean Implements ICommandHandler.CanHandleCommand
useNextHandler = Not(command = ReportCommand.NewReport)
Return Not useNextHandler
End Function
Public Sub HandleCommand(ByVal command As ReportCommand, ByVal args() As Object) Implements ICommandHandler.HandleCommand
Dim i As Integer = ChooseReport()
If i <> -1 Then
Me.panel.OpenReport(CreateReport(i))
End If
End Sub
Private Function ChooseReport() As Integer
Me.chooser.ShowDialog()
Return Me.chooser.Index
End Function
Private Function CreateReport(ByVal index As Integer) As XtraReport
Dim report As New XtraReport()
Select Case index
Case 1
report = New Report1()
Case 2
report = New Report2()
Case Else
report.Bands.Add(New DetailBand())
End Select
Return report
End Function
End Class
End Class
End Namespace