Home > DeveloperSection > Articles > Hosting Crystal Report in Windows Form

Hosting Crystal Report in Windows Form


Crystal Report Crystal Report 
Ratings:
0 Comment(s)
 6172  View(s)
Rate this:

Hosting Crystal Report in Windows Form

Here I am going to explain how to host a crystal report in windows application form (visual studio 2010) after creating a crystal report.

Here, I have created a crystal report with some fields of the database object i.e. product_id, product_name, product_quantity from product table.

Hosting Crystal Report in Windows Form

After creating a report you have to host it in your application. Steps for hosting crystal report in an application.

·         Drags the Crystal Report Viewer control from toolbox drop it into windows form.

·         Drag the button from toolbox and drop it into windows form.

 

Hosting Crystal Report in Windows Form

·         Use namespaces in your application as given below:


using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Windows.Forms;

 

·         On the click event of button write some code as mentioned below:

 

private void button1_Click (object sender, EventArgs e)

       {

         ReportDocument cryRpt = new ReportDocument ();

         cryRpt.Load ("D:\\rohit\\crystal reports\\CrystalReport1.rpt"); //crystal report
                                                                           path

         crystalReportViewer1.ReportSource = cryRpt;

         crystalReportViewer1.Refresh ();

       }

     After performing the above tasks you can see the output by running your application.

Hosting Crystal Report in Windows Form

Click on the Show Report button to see a report.


Don't want to miss updates? Please click the below button!

Follow MindStick