Using the Windows Forms Report Viewer
Now that you have a report ready to run and you're familiar with the reports designer, you can create a form to actually view your report.The first step is to add a new form to your solution by right-clicking the project name in the Solution Explorer and selecting Add, Add Windows Form from the contextual menu. You can leave the default Form1.vb or Form1.cs name.Next, in the Toolbox, scroll down in the Windows Forms tab until you see the CrystalReportViewer control. Drag it onto your form, and set the Dock property to Fill so that it resizes with the form. Your form should look something like Figure 18.18.
Figure 18.18. Form1 after adding the CrystalReportViewer control.

The viewer on its own does nothing. You can either set a binding property to specify the report to load or you can programmatically load a report into the viewer. To view the Report1.rpt you created, press the F4 key to view the properties for the viewer control and select the ReportSource property. If you click the Browse option in the ReportSource property, the Open An Existing Crystal Report dialog pops up. Navigate to the correct directory of this solution and select Report1.rpt, as Figure 18.19 demonstrates.
Figure 18.19. Selecting the ReportSource for the CrystalReportViewer control.

After that property is set, you can press the F5 key to run the application. Like magic, the report that you created is displayed in a nice full-featured report viewer. Figure 18.20 is what you should see now.
Figure 18.20. Viewing the Report1.rpt in the report viewer.

The toolbar on the viewer enables you to page through, drill into (if it's a group report), print, and export a report. The exporting features of Crystal are especially useful. You have the option of exporting any report to an Excel spreadsheet, Word document, rich text document, or Adobe PDF document.
• Table of Contents
• Index
Sams Teach Yourself Visual Studio® .NET 2003 in 21 Days
By
Jason Beres
Publisher
: Sams Publishing
Pub Date
: January 14, 2003
ISBN
: 0-672-32421-0
Pages
: 696
Sams Teach Yourself Visual Studio .NET in 21 Days will help developers that are new to application development and experienced developers understand how to use the .NET Framework and Visual Studio .NET to rapidly develop any type of computer application. The Visual Studio .NET development environment is the most comprehensive developer tool ever created, putting that together with the .NET Frameworks' Class Libraries, the developer has everything he or she needs to get up-to-speed on Microsoft's latest revolution in application development. This book will guide the developer through using the VS .NET IDE, the Visual Basic .NET and C# language, and the supporting tools available from Microsoft to create Windows and Web-based applications. The market is full of books that pretty much say the same thing, which is already available in the help files, the author of this book has written and deployed over a dozen successful applications using Visual Studio .NET and the .NET Framework. All of his expertise and experience is used to give you the most comprehensive title on using Visual Studio .NET.