crystal report7 我没用过。我用过8与8.5。其作法是这样的。一:In this step, you will add the references, components, forms, and controls for the application.1 Create a new Standard EXE project.2 Add the following components to the project: Crystal Reports Viewer Control Embeddable Crystal Reports 8.5 Designer Control Microsoft Common Dialog 6.0 Microsoft Tabbed Dialog Control 6.0 (Sp4).3 Add the following reference to the project: Crystal Reports 8.5 ActiveX Designer Design and Runtime Library.Note: See Programming the Crystal Report Viewers for more information.4 Add the following controls from the Toolbox to the form: three CommandButton controls Common Dialog (Microsoft Common Dialog Control 6.0) SSTab1 (Microsoft Tabbed Dialog Control 6.0 (SP4)) CRDesignerCtrl (Embeddable Crystal Reports 8.5 Designer Control) CRViewer (Crystal Report Viewer Control).5 Set the properties for the form and the controls: Form1 (Main form for the application): Name = frmMain Caption = Embeddable Crystal Reports 8.5 Designer Control Sample Height = 8265 Width = 10815 SStab (Tabbed control containing the Embeddable Designer and Report Viewer controls):Note: Click the tabs on SSTab1 to access the separate Caption properties. Name = SSTab1 Tabs = 2 Tab1 Caption = Design Tab2 Caption = Preview Enabled = False Height = 7600 Left = 0 Tab Height = 300 Top = 130 Width = 10825 CRDesignerCtrl1 (Designs and edits reports):Note: Place the control on the tab labeled 揇esigner.? Name = CRDesignerCtrl1 Height = 6540 Left = 0 Top = 0 Width = 10325 CRViewer (Views reports): Name = CRViewer1 Height = 10340 Left = 120 Top = 360 Height = 6600 CommonDialog (Creates an Open dialog to select reports): Name = CommonDialog1 Filter = Crystal Reports |*.rpt Button1 (Creates a new report): Name = cmdNewReport Caption = &New Report Left = 120 Top = 7850 Button2 (Opens an existing report): Name = cmdOpenReport Caption = &OpenReport Left = 1950 Top = 7850 Button3 (Closes the form and exits the application): Name = cmdExit Caption = E&xit Left = 9030 Top = 7850二:In this step you will add the code to: create a new report create an Open dialog box to open an existing report set the report object to CRDesignerCtrl1 and view the report in design mode set the report object to CRViewer1, set the zoom level, and view the report refresh the report when switching from the Designer tab to the Viewer tab on the Microsoft Tabbed Dialog Control.1 Type or insert the sample code below into the code module of frmMain.2 Once you have added the code, on the Run menu click Start to run the application.Note: Error handling is not included in the code samples.Option ExplicitDim m_Application As New CRAXDDRT.ApplicationDim m_Report As CRAXDDRT.Report' *************************************************************'DisplayReport is a procedure that' - Enables the Tab control the first time a report is created' or opened.' - Sets the report object to the Embeddable Designer(CRDesigner1).' - Disables the Help menu in the Embeddable Designer.' - Sets the report object to the Crystal Report Viewer Control' (CRViewer1).' - Sets the Crystal Reports Viewer to view the report.'Public Sub DisplayReport()' Enable the tab control if disabled.If SSTab1.Enabled = False Then SSTab1.Enabled = True' Set the Report ObjectCRDesignerCtrl1.ReportObject = m_Report ' Note----------------' Set all other properties for CRDesignerCtrl1 after setting the' ReportObject property' -------------------- ' Disable the Help menuCRDesignerCtrl1.EnableHelp = False' Set the report sourceCRViewer1.ReportSource = m_Report' Set the viewer to view the reportCRViewer1.ViewReport' Set the zoom level to fit the page ' to the width of the viewer windowCRViewer1.Zoom 1End Sub' *************************************************************Private Sub Form_Load()'Set the tab control to display the Designer tab'when the form is loadedSSTab1.Tab = 0End Sub' *************************************************************Private Sub SSTab1_Click(PreviousTab As Integer)' Refresh the report when clicking Preview, ' without refreshing the data from the server.If PreviousTab = 0 Then CRViewer1.RefreshEx FalseEnd Sub' *************************************************************' Create a new report and display it in the Embeddable Designer'Private Sub cmdNew_Click()' Set the report object to nothingSet m_Report = Nothing' Create a new reportSet m_Report = m_Application.NewReport' Call DisplayReport to set the report to the Embeddable Designer' and the Crystal Report Viewer and then display the report in the' Embeddable Designer.Call DisplayReportEnd Sub' *************************************************************' Use the Microsoft Common Dialog control to open a report.'Private Sub cmdOpen_Click()CommonDialog1.CancelError = TrueOn Error GoTo errHandler' Display the open dialog boxCommonDialog1.ShowOpen' Set the report object to nothingSet m_Report = Nothing' Open the selected reportSet m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1)' Call DisplayReport to set the report to the Embeddable Designer' and the Crystal Report ViewerCall DisplayReportExit SuberrHandler:'User cancelled dialogEnd Sub' *************************************************************Private Sub cmdAbout_Click()frmAbout.Show vbModalEnd Sub' *************************************************************Private Sub cmdExit_Click()Unload MeEnd Sub 三: In this step you will: create and design a new report in the Embeddable Designer view the report and any changes made to the report open and edit an existing report in the Embeddable Designer view the report and any changes made to the report.1 With the application running, click New Report. An empty report will appear in the Embeddable Designer. Note: The interface for the Embeddable Designer is the same one used for ActiveX Designer reports created in the Microsoft Visual Basic IDE with the Crystal Reports Report Designer Component.2 Design a new report to view. If you are not familiar with the designer environment, see Designing reports in the Embeddable Designer for a step-by-step procedure on creating a simple report off the Xtreme Sample Database ODBC data source.3 Click Preview to view the report in the Crystal Report Viewer. 4 Click Design and make some changes to the report. Then click Preview to see the changes in the Crystal Report Viewer.5 Click Open.6 In the Open dialog box select one of the sample reports and click Open to view the report in the Embeddable Designer.7 Click Preview to view the report in the Crystal Report Viewer. 8 Click Design and make some changes to the report. Then click Preview to see the changes in the Crystal Report Viewer.
Embeddable Crystal Reports 8.5 Designer Control
Microsoft Common Dialog 6.0
Microsoft Tabbed Dialog Control 6.0 (Sp4).3 Add the following reference to the project: Crystal Reports 8.5 ActiveX Designer Design and Runtime Library.Note: See Programming the Crystal Report Viewers for more information.4 Add the following controls from the Toolbox to the form: three CommandButton controls
Common Dialog (Microsoft Common Dialog Control 6.0)
SSTab1 (Microsoft Tabbed Dialog Control 6.0 (SP4))
CRDesignerCtrl (Embeddable Crystal Reports 8.5 Designer Control)
CRViewer (Crystal Report Viewer Control).5 Set the properties for the form and the controls: Form1 (Main form for the application): Name = frmMain Caption = Embeddable Crystal Reports 8.5 Designer Control Sample Height = 8265 Width = 10815 SStab (Tabbed control containing the Embeddable Designer and Report Viewer controls):Note: Click the tabs on SSTab1 to access the separate Caption properties. Name = SSTab1 Tabs = 2 Tab1 Caption = Design Tab2 Caption = Preview Enabled = False Height = 7600 Left = 0 Tab Height = 300 Top = 130 Width = 10825 CRDesignerCtrl1 (Designs and edits reports):Note: Place the control on the tab labeled 揇esigner.? Name = CRDesignerCtrl1 Height = 6540 Left = 0 Top = 0 Width = 10325 CRViewer (Views reports): Name = CRViewer1 Height = 10340 Left = 120 Top = 360 Height = 6600 CommonDialog (Creates an Open dialog to select reports): Name = CommonDialog1 Filter = Crystal Reports |*.rpt Button1 (Creates a new report): Name = cmdNewReport Caption = &New Report Left = 120 Top = 7850 Button2 (Opens an existing report): Name = cmdOpenReport Caption = &OpenReport Left = 1950 Top = 7850 Button3 (Closes the form and exits the application): Name = cmdExit Caption = E&xit Left = 9030 Top = 7850二:In this step you will add the code to: create a new report create an Open dialog box to open an existing report set the report object to CRDesignerCtrl1 and view the report in design mode set the report object to CRViewer1, set the zoom level, and view the report refresh the report when switching from the Designer tab to the Viewer tab on the Microsoft Tabbed Dialog Control.1 Type or insert the sample code below into the code module of frmMain.2 Once you have added the code, on the Run menu click Start to run the application.Note: Error handling is not included in the code samples.Option ExplicitDim m_Application As New CRAXDDRT.ApplicationDim m_Report As CRAXDDRT.Report' *************************************************************'DisplayReport is a procedure that' - Enables the Tab control the first time a report is created' or opened.' - Sets the report object to the Embeddable Designer(CRDesigner1).' - Disables the Help menu in the Embeddable Designer.' - Sets the report object to the Crystal Report Viewer Control' (CRViewer1).' - Sets the Crystal Reports Viewer to view the report.'Public Sub DisplayReport()' Enable the tab control if disabled.If SSTab1.Enabled = False Then SSTab1.Enabled = True' Set the Report ObjectCRDesignerCtrl1.ReportObject = m_Report ' Note----------------' Set all other properties for CRDesignerCtrl1 after setting the' ReportObject property' -------------------- ' Disable the Help menuCRDesignerCtrl1.EnableHelp = False' Set the report sourceCRViewer1.ReportSource = m_Report' Set the viewer to view the reportCRViewer1.ViewReport' Set the zoom level to fit the page ' to the width of the viewer windowCRViewer1.Zoom 1End Sub' *************************************************************Private Sub Form_Load()'Set the tab control to display the Designer tab'when the form is loadedSSTab1.Tab = 0End Sub' *************************************************************Private Sub SSTab1_Click(PreviousTab As Integer)' Refresh the report when clicking Preview, ' without refreshing the data from the server.If PreviousTab = 0 Then CRViewer1.RefreshEx FalseEnd Sub' *************************************************************' Create a new report and display it in the Embeddable Designer'Private Sub cmdNew_Click()' Set the report object to nothingSet m_Report = Nothing' Create a new reportSet m_Report = m_Application.NewReport' Call DisplayReport to set the report to the Embeddable Designer' and the Crystal Report Viewer and then display the report in the' Embeddable Designer.Call DisplayReportEnd Sub' *************************************************************' Use the Microsoft Common Dialog control to open a report.'Private Sub cmdOpen_Click()CommonDialog1.CancelError = TrueOn Error GoTo errHandler' Display the open dialog boxCommonDialog1.ShowOpen' Set the report object to nothingSet m_Report = Nothing' Open the selected reportSet m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1)' Call DisplayReport to set the report to the Embeddable Designer' and the Crystal Report ViewerCall DisplayReportExit SuberrHandler:'User cancelled dialogEnd Sub' *************************************************************Private Sub cmdAbout_Click()frmAbout.Show vbModalEnd Sub' *************************************************************Private Sub cmdExit_Click()Unload MeEnd Sub
三:
In this step you will: create and design a new report in the Embeddable Designer view the report and any changes made to the report open and edit an existing report in the Embeddable Designer view the report and any changes made to the report.1 With the application running, click New Report. An empty report will appear in the Embeddable Designer. Note: The interface for the Embeddable Designer is the same one used for ActiveX Designer reports created in the Microsoft Visual Basic IDE with the Crystal Reports Report Designer Component.2 Design a new report to view. If you are not familiar with the designer environment, see Designing reports in the Embeddable Designer for a step-by-step procedure on creating a simple report off the Xtreme Sample Database ODBC data source.3 Click Preview to view the report in the Crystal Report Viewer. 4 Click Design and make some changes to the report. Then click Preview to see the changes in the Crystal Report Viewer.5 Click Open.6 In the Open dialog box select one of the sample reports and click Open to view the report in the Embeddable Designer.7 Click Preview to view the report in the Crystal Report Viewer. 8 Click Design and make some changes to the report. Then click Preview to see the changes in the Crystal Report Viewer.