VS2010 creating and using custom data source reports detailed procedures
First look at the final effect (display data is encrypted, so it is garbled)
Figure 1. Effect of the form
Figure 2: Click to preview the effect
1. Create a form that displays a report
Create a new form named Reportform and modify the form name to student score
You only need to drag and drop a ReportViewer control on the form
2. New DataSet is Dsofstudent.xsd
Insert the table structure in the dataset that you want to display in the report (in this case, note that the field name must match the DataTable that you want to pass to the report)
3. Insert the report and name it Studentreport
When new is complete, right-click the Insert table in the report page and select the table in the dataset you just created, as
Then set the background color of the header \ header \ bound display field, as
Let's talk about how to set the color of each row display
Here you choose to set the background as an expression: =iif (fields! Grade.value = 0, "Red", "greenyellow") means that if the Grade is 0, the red color is displayed, otherwise it is yellowish green.
4. Incoming data
Select a report source in the ReportViewer control in the form, as follows
Next, when the form is initialized, the contents of the table to be displayed are passed in
DataSet ds = new DataSet ();
ds = Stu. GetStudentList2 (Sschoolname, Sclassname) (the data set you want to display);
This.reportViewer1.LocalReport.DataSources.Clear ();
THIS.REPORTVIEWER1.LOCALREPORT.DATASOURCES.ADD (New Microsoft.Reporting.WinForms.ReportDataSource ("Stugrade", ds. Tables[0]));
This.reportViewer1.RefreshReport ();
In summary, the creation and use of the VS2010 report custom data source is finished.
If there are imperfect places, please make suggestions, I will improve.
VS2010 creating and using custom data source reports detailed procedures