1

This is how I Show a Report with a Button in a Form:

        private void button1_Click(object sender, EventArgs e)
        {
        ReportDocument rptDoc = new ReportDocument();
        DataSe1t ds = new  DataSet1();
        DataTable dt = new DataTable();


        dt.TableName = "Crystal Report Example";
        dt = getAll(); //This is a function
        ds.Tables[0].Merge(dt);

        string strReportName = "SampleReport.rpt";
        string strPath = Application.StartupPath + "\\Reports\\" + strReportName;
        rptDoc.Load(strPath);

        rptDoc.SetDataSource(ds);
        crystalReportViewer1.ReportSource = rptDoc;

        }

I create a user control and add some control on it. And add that usercontrol into the Form and add CrystalReportViewer into the Form.

How I will load the Reports using a button in a user control?

Square Ponge
  • 702
  • 2
  • 10
  • 26
  • I don't really get what your problem is, simply just register `Click` event handler (which you showed above) with the `Click` event of the button on your `UserControl` – King King Jul 06 '13 at 20:28
  • With the code above button and crystalreportviewer is in one container(Form). What I need is when a button is in usercontrol1. Meaning the button is created inside the usercontrol1. And then usercontrol1 and CrystalReportViewer is added on the form. – Square Ponge Jul 06 '13 at 20:49
  • Check this http://stackoverflow.com/questions/7880850/how-do-i-make-an-event-in-the-usercontrol-and-have-it-handeled-in-the-main-form – David - Jul 06 '13 at 21:59

0 Answers0