期待的消息,终于出现。 收藏以备用。

1) First Look At The DevExpress LightSwitch Reporting Control 

     http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/32/First-Look-At-The-DevExpress-LightSwitch-Reporting-Control.aspx

2)How to: Use XtraReports in LightSwitch Applications

     http://documentation.devexpress.com/#XtraReports/CustomDocument9901

This tutorial will guide you through the process of creating a simple LightSwitch application containing a report using Microsoft® Visual Studio® 2010 or Visual Studio® LightSwitch™. You will learn how to add a report to a LightSwitch application and bind it to a data source.

To create a data-aware report in a LightSwitch application, do the following.

Create a LightSwitch Application with an XtraReports Extension

  1. Run Microsoft® Visual Studio® 2010 or Visual Studio® LightSwitch™.

  2. Start a new project (CTRL+SHIFT+N) and create a new LightSwitch Application.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  3. Switch to the Solution Explorer (CTRL+ALT+L), right-click Application1, and in the invoked menu, click Properties.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  4. Then, in the Application Designer, switch to Extensions, and enable the check box near the DevExpress.XtraReports.LightSwitch extensions, to add it to the application.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

    Click Save to apply the changes, and close the Application Designer.

  5. Back in the Solution Explorer, right-click the Data Sources folder and in the invoked menu, click Add Data Source...

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  6. On the first page of the invoked wizard, choose WCF RIA Service and click Next.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  7. On the next page, the XtraReportsService is selected by default, so click Next.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  8. On the last page, choose to include all entities and click Finish.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

DevExpress  发布 Free 的 Lightswitch 打印报表控件.DevExpress  发布 Free 的 Lightswitch 打印报表控件.Note

We do not recommend you change the data source name from its default value (XtraReportsServiceData), as well as names of other auto-generated entities and their attributes. Otherwise, the application will not work.

Add a Data Source to the Application

Although the following steps demonstrate how to use an external data source in your LightSwitch application, XtraReports fully supports working with intrinsic data sources as well.

  1. In the Solution Explorer, right-click the Data Sources folder and in the invoked menu, click Add Data Source...

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  2. At this time, choose Database in the wizard, and click Next.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  3. In the invoked Choose Data Source dialog, choose Microsoft SQL Server and click Continue.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  4. Next, in the Connection Properties dialog, specify the server name, authentication mode and your database name.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

    Test the connection and click OK to proceed.

  5. On the last wizard page, select the required table(s), and click Finish.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

Add a Report to the Application

  1. In the Solution Editor, switch to the File View.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

    Then, right-click Server, and in the invoked menu, choose Add | New Item...

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  2. In the Add New Item dialog, select the XtraReport Class v11.1 item, and click Add.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

Bind the Report to Data and Adjust Its Layout

  1. After the report is added, re-build your application.

    Then, click the report's smart tag and in its actions list, invoke the drop-down list for the XtraReportBase.DataSource property and choose the existing data source.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  2. Following this step, the Field List reflects the structure of your report's data source, and can be used to create data-aware controls.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  3. To group a report's data, use the Group and Sort panel. To show this panel, right-click your report and in the invoked menu, choose Tool Windows and click Group And Sort.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

    Then, group the report by the Country field...

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

    ... and drop the corresponding item from the Field List onto the created Group Header band.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  4. To provide a Document Map to your report, bind the XRControl.Bookmark property of the created XRLabel to the same data field.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

Add a Screen and Show the Report

  1. In the Solution Explorer, select Screens, and in the invoked menu, choose Add Screen...

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  2. In the Add New Screen dialog, select List and Detail Screen, and set the Screen Data to the selected table.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  3. In the application designer, right-click the Screen Command Bar, and choose Add Button...

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  4. In the Add Button dialog, specify the name for the corresponding method, and click OK.

    DevExpress  发布 Free 的 Lightswitch 打印报表控件.

  5. Handle the Execute() method of the button, and call the ReportPreview.Show() method with the specified report name (including its namespace).

DevExpress  发布 Free 的 Lightswitch 打印报表控件.
C#
VB
DevExpress  发布 Free 的 Lightswitch 打印报表控件.
partial void ShowTheReport_Execute() {
    ReportPreview.Show("LightSwitchApplication.XtraReport1");
}
C#
partial void ShowTheReport_Execute() {
    ReportPreview.Show("LightSwitchApplication.XtraReport1");
}
VB
Private Sub ShowTheReport_Execute()
    ReportPreview.Show("XtraReport1")
End Sub 

View the Result

Run the application and click Show The Report.

DevExpress  发布 Free 的 Lightswitch 打印报表控件.

The result is shown in the following image.

DevExpress  发布 Free 的 Lightswitch 打印报表控件.

 See Also

相关文章: