Public Class Form1
Inherits System. Windows. Forms. Form
# Region "code generated by Windows Form Designer"
Public Sub New ()
MyBase. New ()
'The call is required by the Windows Form Designer.
InitializeComponent ()
'Add any initialization after InitializeComponent () is called.
End Sub
'Form rewriting disposal to clear the component list.
Protected Overloads Overrides Sub Dispose (ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
Components. Dispose ()
End If
End If
MyBase. Dispose (disposing)
End Sub
'Windows forms designer required
Private components As System. ComponentModel. IContainer
'Note: The following procedure is required by the Windows Forms designer
'You can use the Windows Form Designer to modify this process.
'Do not use the code editor to modify it.
Friend WithEvents PictureBox1 As System. Windows. Forms. PictureBox
Friend WithEvents SSTab1 As System. Windows. Forms. TabControl
Friend WithEvents TabPage2 As System. Windows. Forms. TabPage
Friend WithEvents TabPage1 As System. Windows. Forms. TabPage
Friend WithEvents AxCRDesignerCtrl101 As AxCRDESIGNERCTRLLib10.AxCRDesignerCtrl10
Friend WithEvents AxCrystalActiveXReportViewer1 As AxCrystalActiveXReportViewerLib10.AxCrystalActiveXReportViewer
Friend WithEvents ToolBar1 As System. Windows. Forms. ToolBar
Friend WithEvents tbbNew As System. Windows. Forms. ToolBarButton
Friend WithEvents tbbOpen As System. Windows. Forms. ToolBarButton
Friend WithEvents tbbSave As System. Windows. Forms. ToolBarButton
Friend WithEvents tbbClose As System. Windows. Forms. ToolBarButton
<System. Diagnostics. DebuggerStepThrough ()> Private Sub InitializeComponent ()
Dim resources As System. Resources. ResourceManager = New System. Resources. ResourceManager (GetType (Form1 ))
Me. PictureBox1 = New System. Windows. Forms. PictureBox
Me. SSTab1 = New System. Windows. Forms. TabControl
Me. TabPage1 = New System. Windows. Forms. TabPage
Me. AxCRDesignerCtrl101 = New AxCRDESIGNERCTRLLib10.AxCRDesignerCtrl10
Me. TabPage2 = New System. Windows. Forms. TabPage
Me. AxCrystalActiveXReportViewer1 = New AxCrystalActiveXReportViewerLib10.AxCrystalActiveXReportViewer
Me. ToolBar1 = New System. Windows. Forms. ToolBar
Me. tbbNew = New System. Windows. Forms. ToolBarButton
Me. tbbOpen = New System. Windows. Forms. ToolBarButton
Me. tbbSave = New System. Windows. Forms. ToolBarButton
Me. tbbClose = New System. Windows. Forms. ToolBarButton
Me. SSTab1.SuspendLayout ()
Me. TabPage1.SuspendLayout ()
CType (Me. AxCRDesignerCtrl101, System. ComponentModel. ISupportInitialize). BeginInit ()
Me. TabPage2.SuspendLayout ()
CType (Me. AxCrystalActiveXReportViewer1, System. ComponentModel. ISupportInitialize). BeginInit ()
Me. SuspendLayout ()
'
'Picturebox1
'
Me. PictureBox1.BackColor = System. Drawing. SystemColors. ActiveCaptionText
Me. PictureBox1.Location = New System. Drawing. Point (624, 8)
Me. PictureBox1.Name = "PictureBox1"
Me. PictureBox1.Size = New System. Drawing. Size (96, 32)
Me. PictureBox1.TabIndex = 3
Me. PictureBox1.TabStop = False
'
'Sstab1
'
Me. SSTab1.Controls. Add (Me. TabPage1)
Me. SSTab1.Controls. Add (Me. TabPage2)
Me. SSTab1.ItemSize = New System. Drawing. Size (0, 17)
Me. SSTab1.Location = New System. Drawing. Point (0, 40)
Me. SSTab1.Name = "SSTab1"
Me. SSTab1.SelectedIndex = 0
Me. SSTab1.Size = New System. Drawing. Size (728,528)
Me. SSTab1.TabIndex = 2
'
'Tabpage1
'
Me. TabPage1.Controls. Add (Me. AxCRDesignerCtrl101)
Me. TabPage1.Location = New System. Drawing. Point (4, 21)
Me. TabPage1.Name = "TabPage1"
Me. TabPage1.Size = New System. Drawing. Size (720,503)
Me. TabPage1.TabIndex = 0
Me. TabPage1.Text = "design"
'
'Axcrdesignerctrl101
'
Me. AxCRDesignerCtrl101.ContainingControl = Me
Me. AxCRDesignerCtrl101.Enabled = True
Me. AxCRDesignerCtrl101.Location = New System. Drawing. Point (0, 0)
Me. AxCRDesignerCtrl101.Name = "AxCRDesignerCtrl101"
Me. AxCRDesignerCtrl101.OcxState = CType (resources. GetObject ("AxCRDesignerCtrl101.OcxState"), System. Windows. Forms. AxHost. State)
Me. AxCRDesignerCtrl101.Size = New System. Drawing. Size (720,504)
Me. AxCRDesignerCtrl101.TabIndex = 0
'
'Tabpage2
'
Me. TabPage2.Controls. Add (Me. AxCrystalActiveXReportViewer1)
Me. TabPage2.Location = New System. Drawing. Point (4, 21)
Me. TabPage2.Name = "TabPage2"
Me. TabPage2.Size = New System. Drawing. Size (720,503)
Me. TabPage2.TabIndex = 1
Me. TabPage2.Text = "preview"
'
'Axcrystalactivexreportviewer1
'
Me. AxCrystalActiveXReportViewer1.ContainingControl = Me
Me. AxCrystalActiveXReportViewer1.Enabled = True
Me. AxCrystalActiveXReportViewer1.Location = New System. Drawing. Point (0, 0)
Me. AxCrystalActiveXReportViewer1.Name = "AxCrystalActiveXReportViewer1"
Me. AxCrystalActiveXReportViewer1.OcxState = CType (resources. GetObject ("AxCrystalActiveXReportViewer1.OcxState"), System. Windows. Forms. AxHost. State)
Me. AxCrystalActiveXReportViewer1.Size = New System. Drawing. Size (720,496)
Me. AxCrystalActiveXReportViewer1.TabIndex = 0
'
'Toolbar1
'
Me. ToolBar1.Buttons. AddRange (New System. Windows. Forms. ToolBarButton () {Me. tbbNew, Me. tbbOpen, Me. tbbSave, Me. tbbClose })
Me. ToolBar1.DropDownArrows = True
Me. ToolBar1.Location = New System. Drawing. Point (0, 0)
Me. ToolBar1.Name = "ToolBar1"
Me. ToolBar1.ShowToolTips = True
Me. ToolBar1.Size = New System. Drawing. Size (728, 41)
Me. ToolBar1.TabIndex = 6
'
'Tbbnew
'
Me. tbbNew. Text = "New"
'
'Tbbopen
'
Me. tbbOpen. Text = "Open"
'
'Tbbsave
'
Me. tbbSave. Text = "Save"
'
'Tbbclose
'
Me. tbbClose. Text = "Close"
'
'Form1
'
Me. AutoScaleBaseSize = New System. Drawing. Size (6, 14)
Me. ClientSize = New System. Drawing. Size (728,573)
Me. Controls. Add (Me. ToolBar1)
Me. Controls. Add (Me. SSTab1)
Me. Name = "Form1"
Me. Text = "customized for reports"
Me. SSTab1.ResumeLayout (False)
Me. TabPage1.ResumeLayout (False)
CType (Me. AxCRDesignerCtrl101, System. ComponentModel. ISupportInitialize). EndInit ()
Me. TabPage2.ResumeLayout (False)
CType (Me. AxCrystalActiveXReportViewer1, System. ComponentModel. ISupportInitialize). EndInit ()
Me. ResumeLayout (False)
End Sub
# End Region
Dim m_Application As New CRAXDDRT. Application
Dim m_Report As CRAXDDRT. Report
'++ ++ +
'The version uses the advanced development version of Crystal Report 10, and cannot use the Enterprise Edition, because the Enterprise Edition lacks control support.
'The program needs to use CRDesignerCtrl. DLL, and then reference crystal reports activex designer design and ruantime library 10.0 by COM.
'The program also needs to add two com components, embeddable crystal reports designer control 10.0 and crystal activex report viewer control 10.0.
'.
'++ ++ +
Private Sub Form1_Load (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles MyBase. Load
SSTab1.TabIndex = 0
AxCrystalActiveXReportViewer1.EnableExportButton = True
AxCRDesignerCtrl101.DisplayToolbar = True
End Sub
Public Sub DisplayReport ()
AxCRDesignerCtrl101.ReportObject = m_Report 'specifies the report source of the design control.
AxCRDesignerCtrl101.EnableHelp = False
AxCrystalActiveXReportViewer1.ReportSource = m_Report 'specifies the report source of the preview control.
AxCrystalActiveXReportViewer1.Zoom (1)
AxCrystalActiveXReportViewer1.ViewReport ()
End Sub
Private Sub ToolBar1_ButtonClick (ByVal sender As System. Object, ByVal e As System. Windows. Forms. ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Try
Select Case Trim (e. Button. Text)
Case "New"
M_Report = Nothing
M_Report = m_Application.OpenReport (Application. StartupPath & "/Report1.rpt", 1) 'Open the blank rpt
DisplayReport ()
Case "Open"
Dim dlg As New OpenFileDialog
Dlg. Title = "select rpt Format File"
Dlg. Filter = "Crystal Reports (*. rpt) | *. rpt | All Files (*. *) | *.*"
Dlg. InitialDirectory = "C:/Program Files/Microsoft Visual Studio. NET/Crystal Reports/Samples/Reports"
If (dlg. ShowDialog () = DialogResult (). OK) Then
M_Report = Nothing
Me. Cursor = Cursors. WaitCursor 'defines the mouse Style
M_Report = m_Application.OpenReport (dlg. FileName, 1) 'open an existing rpt
Me. Cursor = Cursors. Default
DisplayReport ()
End If
Dlg. Dispose () 'releases the dialog resource. Otherwise, an error occurs.
Case "Save"
Dim dlgSave As New SaveFileDialog
DlgSave. Title = "Save the rpt Format File"
DlgSave. Filter = "Crystal Reports (*. rpt) | *. rpt"
DlgSave. InitialDirectory = "c :/"
If (dlgSave. ShowDialog () = DialogResult. OK) Then
M_Report.SaveAs (dlgSave. FileName, CRAXDDRT. CRReportFileFormat. crDefaultFileFormat) 'Save the modified rpt
End If
DlgSave. Dispose () 'releases the dialog resource. Otherwise, an error occurs.
Case "Close"
M_Report = Nothing
Me. Close ()
End Select
Catch ex As Exception
MessageBox. Show (ex. Message)
End Try
End Sub
Private Sub Form1_Closing (ByVal sender As Object, ByVal e As System. ComponentModel. CancelEventArgs) Handles MyBase. Closing
Me. AxCRDesignerCtrl101.Dispose () 'release control resources
Me. AxCrystalActiveXReportViewer1.Dispose ()
End Sub
End Class