Danh mục

Display a Report That was Created

Số trang: 6      Loại file: pdf      Dung lượng: 22.24 KB      Lượt xem: 3      Lượt tải: 0    
thaipvcb

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

10,2 Hiển thị một báo cáo được tạo ra Bản báo cáo không làm tôi rất nhiều trong thiết kế tốt chế độ. Làm thế nào để đi về xem báo cáo? Kỹ thuật Bạn có thể xem một báo cáo trong một vài cách khác nhau. Bạn có thể xem một báo cáo hoặc sử dụng một Form hay Windows Form một Web
Nội dung trích xuất từ tài liệu:
Display a Report That was Created 10.2 Display a Report That Was CreatedThe report doesnt do me much good in Design mode. How do I go about viewing thereport?TechniqueYou can review a report in a couple of ways. You can view a report either using aWindows Form or a Web Form. Either way, you will also use a control called the CrystalReport Viewer.Introducing the Crystal Report ViewerThe Crystal Report Viewer is a control that is available in the Toolbox. It is the lastcontrol by default. Crystal Report Viewer does far more than just let you view yourdocument on the form. With the Viewer, you can do any of the following: • View the report on the form. • Zoom in and out on the document. • Expand and collapse groupings on the document. • Print from the Viewer. • Export from the Viewer. • Move around in the document • Search for text within the report.You can see an example of the Crystal Report Viewer on a Windows Form in Figure10.11, where the example form from this How-To is displayed. Figure 10.11. The Crystal Report Viewer provides the user with several features, but most of the features can be disabled if necessary.Sometimes you might not want the user to have all the features that come with theViewer. The good news is that the Viewer actually has its own object model whereby youcan set some of the properties at design time or runtime. The Viewer even has an eventmodel that you can program. You can see the object model for the Windows FormCrystalReportViewer in Figure 10.12. Figure 10.12. Using the object model displayed here, you have almost complete control over the Viewer behavior.Although you can make the Viewer stand on its head using the object model, to getstarted, you really only have to set one property: the ReportSource.Just as it sounds, the ReportSource tells the Viewer which report to display. You can setthe ReportSource in a variety of ways. You can set the ReportSource property to the filepath and name of a report, or you can create what is called a strongly typed reportdocument.Specifying the ReportSource by Using the ReportTo specify a report file, click on the down arrow in the ReportSource property, andchoose (Browse). The Open an Existing Crystal Report dialog box opens. There, you canlook for the report that you want to assign within your project folder.The bad part about assigning the report file directly is that when you move theapplication, the file path is not updated. A better way to assign the ReportSource is to usea Report Document to strongly type the report.Specifying the ReportSource Using a Strong Typed ReportWhen youre using strong typed reports, you can move your application and the reportfile without having to re-establish the file path to the report. To accomplish this, you usewhat is called a Report document. You can find the Report document in the Componentlist. In there, it is called ReportDocument.When you pull the ReportDocument component onto your form, you are asked to supplya report to be strong typed. After you have chosen your report, the ReportDocumentappears in your Component tray. When you assign the ReportSource, theReportDocument appears first in the list (see Figure 10.13). Figure 10.13. Using the ReportDocument is the way to go when youre assigning reports to Viewers.StepsOpen and run the Visual Basic .NET-Chapter 10 solution. Click on the button labeledHow-To 10.2. You immediately see the report show up that was created in the last How-To. Play with the toolbar buttons on the Viewer to see how they work. When youmaximize the form, you the Viewer expands as well. That is because the Viewer isanchored (see Figure 10.14). 1. Create a Windows Form. 2. Drag a CrystalReportViewer control from the toolbox onto the form.3. Drag a Report document from the Component list onto the form. Type the report name you created in the first How-To (see Figure 10.15). Figure 10.15. This report is strongly typed. Tip After you have clicked OK to accept the Report document, you might want to set the Name property of the control to a name with an rd prefix. I named mine rdHowTo10_2. That way, in later code, I know I am dealing with a ReportDocument control.4. Set the ReportSource property of the CrystalReportViewer control to the name of your Report document.5. Set the Anchor property of the Viewer to be Top, Bottom, Left, Right. This ensures that the Viewer fills the form, regardless of the size of the form. Figure 10.14. The report displayed in the Crystal Report Viewer.CommentsThats it, if you open the form now, you will see the report displayed in the form. You getso many features with the Crystal Report Viewer just by dumping it on the form with nocode.

Tài liệu được xem nhiều: