1. Report design: for common rdlc reports, you must add database data sources. In this case, the database must be bound. Here, the report and database are separated. Initialize the report in the form and assign values to the report. 2. Report design: Create a report Report1.rdlc, add a data source, select an object, and select Person at the Mode layer.
3. Set the report data source, design the report interface, drag the table, and assign the field of the Person object to the table. Then set the report data source
Menu: Report/data source,
Modify the data source name of the report to myds.
Set the data source name of the table in the report: myds
4. Load the report and drag the ReportView in the Form Designer.
Select the report you just added, and then delete the "* DataSource" automatically added to the page"
5. The code for initializing the report is as follows:
Code List <Person> listPerson = new List <Person> ();
Person per = new Person ("123", 25 );
ListPerson. Add (per );
DataSet orderSet = new DataSet ();
OrderSet = DataSetHelper. ToDataSet <Person> (listPerson as IList <Person> );
This. reportViewer. LocalReport. CES. Clear ();
// This. reportViewer. LocalReport. CES. Add (new Microsoft. Reporting. WinForms. ReportDataSource ("myds", DataSetHelper. ToDataTable (listPerson as IList <Person> )));
This. reportViewer. LocalReport. CES. Add (new Microsoft. Reporting. WinForms. ReportDataSource ("myds", listPerson. ToArray <Person> ()));
This. reportViewer. RefreshReport ();