如何把crystalReport報表應用于Windows應用程序.
发表于:2007-06-30来源:作者:点击数:
标签:
自己設計好報表,(等下我再講講如何設計吧) 以下是一些 VB 代碼.請大家參考. Public Class Form1 Inherits System.Windows.Forms.Form #Region Windows Form Designer generated code Public Sub New() MyBase.New() InitializeComponent() End Sub @#Form ove
自己設計好報表,(等下我再講講如何設計吧)
以下是一些
VB代碼.請大家參考.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
@#Form overrides dispose to clean up 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
Private WithEvents btnSelectReport As System.Windows.Forms.Button
Private WithEvents crystalReportViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer
Private components As System.ComponentModel.Container
<System.Diagnostics.De
buggerStepThrough()> Private Sub InitializeComponent()
Me.btnSelectReport = New System.Windows.Forms.Button()
Me.crystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer()
Me.btnSelectReport.Location = New System.Drawing.Point(8, 8)
Me.btnSelectReport.Size = New System.Drawing.Size(112, 32)
Me.btnSelectReport.TabIndex = 0
Me.btnSelectReport.Text = "Select Report"
Me.crystalReportViewer.ActiveViewIndex = -1
Me.crystalReportViewer.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.crystalReportViewer.Location = New System.Drawing.Point(8, 48)
Me.crystalReportViewer.ReportSource = Nothing
Me.crystalReportViewer.Size = New System.Drawing.Size(640, 416)
Me.crystalReportViewer.TabIndex = 1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(659, 472)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.crystalReportViewer, Me.btnSelectReport})
Me.Text = "View a Crystal Report"
End Sub
#End Region
Private Sub btnSelectReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectReport.Click
Dim dlg As New OpenFileDialog()
dlg.Title = "Select Crystal Reports 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
Me.Cursor = Cursors.WaitCursor
crystalReportViewer().ReportSource = dlg.FileName
Me.Cursor = Cursors.Default
End If
End Sub
End Class
原文转自:http://www.ltesting.net