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?