⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 一个很好用的报表控件
💻 FRM
字号:
VERSION 5.00
Object = "{2A3A1C01-F9DB-11D3-808E-00A0C9DAC83F}#8.5#0"; "CRDesignerCtrl.DLL"
Object = "{C4847593-972C-11D0-9567-00A0C9273C2A}#8.0#0"; "crviewer.dll"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6450
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8355
   LinkTopic       =   "Form1"
   ScaleHeight     =   6450
   ScaleWidth      =   8355
   StartUpPosition =   3  'Windows Default
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   4320
      Top             =   5880
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdOpen 
      Caption         =   "&OpenReport"
      Height          =   495
      Left            =   2040
      TabIndex        =   4
      Top             =   5880
      Width           =   1215
   End
   Begin VB.CommandButton cmdNew 
      Caption         =   "&NewReport"
      Height          =   495
      Index           =   0
      Left            =   480
      TabIndex        =   3
      Top             =   5880
      Width           =   1215
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   5655
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   8055
      _ExtentX        =   14208
      _ExtentY        =   9975
      _Version        =   393216
      Tabs            =   2
      TabHeight       =   520
      TabCaption(0)   =   "Design"
      TabPicture(0)   =   "Form1.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "CRDesignerCtrl1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).ControlCount=   1
      TabCaption(1)   =   "Preview"
      TabPicture(1)   =   "Form1.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "CRViewer1"
      Tab(1).ControlCount=   1
      Begin CRVIEWERLibCtl.CRViewer CRViewer1 
         Height          =   5175
         Left            =   -74880
         TabIndex        =   2
         Top             =   360
         Width           =   7815
         DisplayGroupTree=   -1  'True
         DisplayToolbar  =   -1  'True
         EnableGroupTree =   -1  'True
         EnableNavigationControls=   -1  'True
         EnableStopButton=   -1  'True
         EnablePrintButton=   -1  'True
         EnableZoomControl=   -1  'True
         EnableCloseButton=   -1  'True
         EnableProgressControl=   -1  'True
         EnableSearchControl=   -1  'True
         EnableRefreshButton=   -1  'True
         EnableDrillDown =   -1  'True
         EnableAnimationControl=   -1  'True
         EnableSelectExpertButton=   0   'False
         EnableToolbar   =   -1  'True
         DisplayBorder   =   -1  'True
         DisplayTabs     =   -1  'True
         DisplayBackgroundEdge=   -1  'True
         SelectionFormula=   ""
         EnablePopupMenu =   -1  'True
         EnableExportButton=   0   'False
         EnableSearchExpertButton=   0   'False
         EnableHelpButton=   0   'False
      End
      Begin CRDESIGNERCTRLLibCtl.CRDesignerCtrl CRDesignerCtrl1 
         Height          =   5295
         Left            =   0
         OleObjectBlob   =   "Form1.frx":0038
         TabIndex        =   1
         Top             =   360
         Width           =   7935
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const OpenDialogFilter As String = "Crystal Reports |*.rpt"
Private errString, errTitle As String

Dim m_Application As New CRAXDDRT.Application
Dim m_Report As CRAXDDRT.Report
Public Sub DisplayReport()
On Error GoTo errhandler
If SSTab1.Enabled = False Then SSTab1.Enabled = True
CRDesignerCtrl1.ReportObject = m_Report
CRDesignerCtrl1.EnableHelp = False
CRViewer1.ReportSource = m_Report
'设置放大级别以适应显示宽度
CRViewer1.Zoom 1
CRViewer1.ViewReport
Exit Sub
errhandler:
    errString = "Error # " & CStr(Err.Number) & " " & Err.Description
    errTitle = Err.Source
    MsgBox errString, vbCritical, errTitle
End Sub

Private Sub cmdNew_Click(Index As Integer)
'用户单击了创建新报表的按钮
On Error GoTo errhandler
Set m_Report = Nothing
'建立一个新报表
Set m_Report = m_Application.NewReport
'调用DisplayReport过程以创建新报表
Call DisplayReport

Exit Sub
errhandler:
    errString = "Error # " & CStr(Err.Number) & " " & Err.Description
    errTitle = Err.Source
    MsgBox errString, vbCritical, errTitle
End Sub

Private Sub cmdOpen_Click()
'打开一个存在的报表
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.Filter = OpenDialogFilter
'显示打开文件对话框
CommonDialog1.ShowOpen
Set m_Report = Nothing
'打开选择的报表
Set m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1)
'调用DisplayReport过程将打开的报表显示在报表设计器中供编辑
Call DisplayReport
Exit Sub
errhandler:
Select Case Err.Number
Case 32755
    'User cancelled dialog
Case Else
    errString = "Error # " & CStr(Err.Number) & " " & Err.Description
    errTitle = Err.Source
    MsgBox errString, vbCritical, errTitle
End Select

End Sub

Private Sub Form_Load()
SSTab1.Tab = 0
End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
If PreviousTab = 0 Then CRViewer1.RefreshEx False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -