Crystal Reports Viewer in Visual Studio 2010

2020-02-06 17:06发布

问题:

I'm using Visual Studio 2010 and already downloaded CR (Crystal Reports) but when I search for Crystal Reports viewerin the tool, does not exist, so how can I display my report that is already created?

And whether there is a tutorial using ReportViewer?

回答1:

The CrystalReport Viewer control is a .Net assembly. By default, when you create a new .net 4 Windows Form application, it uses the .net 4 Client Profile framework, not the standard .net 4 framework. After I converting the project to the standard framework, the Crystal Report Viewer control becomes available under the Reports section.

To view this tool you must change the build configuration of your project.

1) Select a project node in Solution Explorer.

2) On the Project menu, click Properties. When the Project Designer appears, click the Compile tab.

3) On the Compile Page, Project Designer (Visual Basic), select the Configuration and Platform. In simplified build configurations, the Configuration and Platform lists are not displayed. For more information, see Debug and Release Project Configurations.

4) Click Advanced Compile Options.

5) Change Target framework (all configurations): .NET Framework 4



回答2:

Right click on the toolbox, select Crystal Reports Viewer from the available list of WPF components. Now it'll appear in the toolbox and can be used.

Good tutorial here:

http://aspalliance.com/1991_Using_the_New_WPF_Viewer_with_SAP_Crystal_Reports_for_Visual_Studio_2010.2



回答3:

Click on "Project" from menu bar. Select your project's properties. From the target framework select ".NET Framework 4" instead of ".NET Framework 4 Client Profile". A prompt window will open, click on yes button. Now crystal report viewer is yours.



回答4:

You need to First Change Your Framwork to .net Framwork 4.0 Link http://www.aspsnippets.com/Articles/Crystal-Report-Viewer-missing-from-ToolBox-in-Visual-Studio-2010.aspx


After the Change Framwork You Need to install Crystal Report Runtime http://scn.sap.com/docs/DOC-7824


You Can Also Create Crystal Report at Runtime...

[In VB.Net]

Imports CrystalDecisions.Windows.Forms

Private Sub CrystalView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
        Dim crv As New CrystalReportViewer
        With crv
            .Dock = DockStyle.Fill
        End With
        Me.Controls.Add(crv)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

[In C#]
using CrystalDecisions.Windows.Forms;
public class CrystalView
{
    private void CrystalView_Load(System.Object sender, System.EventArgs e)
    {
        try {
            CrystalReportViewer crv = new CrystalReportViewer();
             crv.Dock = DockStyle.Fill;
            crv.EnableDrillDown = false;
            this.Controls.Add(crv);
        } catch (Exception ex) {
            MessageBox.Show(ex.Message,"Hello");
        }
    }
    public CrystalView()
    {
        Load += CrystalView_Load;
    }
}

in Your WinForm Crystal Report Viewer is Visible...