VS2010 creating and using custom data source reports detailed procedures

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.