adspace
Answer Posted / Vijay Pratap Singh Chauhan
In Windows Forms, you can generate a report using a ReportViewer control. Here is an example:
```csharp
private void GenerateReport()
{
// Create a new instance of the ReportViewer
ReportViewer reportViewer = new ReportViewer();
// Load the report from a local RDLC file
LocalReport report = new LocalReport();
report.LoadReportDefinition(Path.GetFullPath("MyReport.rdlc"));
// Set the data source for the report to a DataTable containing your data
DataTable dataSource = GetData();
ReportDataSource reportDataSource = new ReportDataSource("MyDataSet", dataSource);
// Assign the DataSource to the ReportViewer
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(reportDataSource);
// Refresh the report viewer
reportViewer.RefreshReport();
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category