Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
81
Добавлен:
11.05.2015
Размер:
2.11 Mб
Скачать

With the Report Designer Component, you build a report much like the way you build a form in Visual Basic:

call up the designer,

add objects,

set properties,

code events and methods, and

move on to the next part of your application, all without leaving Visual Basic.

The Report Designer Component vs. Seagate Crystal Reports

If you have used Seagate Crystal Reports, you will notice several similarities between the Report Designer Component’s design window and the Seagate Crystal Reports Design Tab. However, there are some major differences to building reports inside Visual Basic with the Report Designer Component.

Each section of the report is itself an object which has a Format event associated with it. When you double-click on any of the sections of the report, the Visual Basic code window opens displaying an event procedure for the Format event of that section. The Format event is invoked at runtime whenever the section is displayed and formatted.

Because the Report Designer Component produces Visual Basic executable code, you can use Visual Basic for creating calculated fields and formulas in addition to using the built-in formula language.

Your reports typically become an embedded part of the executable. This has implications for individuals who might want to later modify reports using standalone versions of Seagate Crystal Reports.

Despite these facts, you will find that you can quickly leverage your existing Seagate Crystal Reports knowledge to develop reports. While working with the Seagate Crystal Report Designer Component, though, keep in mind all of the following features.

The following topics are discussed in this section:

Data Access, Page 148

No drag and drop between reports – use copy and paste, Page 148

Conditional Formatting, Page 148

Preview Window, Page 149

Pictures, Page 149

Guidelines, Page 149

Subreports, Page 149

The dual formula environment, Page 150

Application Distribution, Page 151

The Report Designer Component

147

Data Access

The Report Designer Component supports data access through Data Access Objects (DAO), Remote Data Objects (RDO), and ActiveX Data Objects (ADO). Through these three access methods, you can connect to most ISAM, ODBC, and SQL data sources available to Windows applications. In addition, you can create DAO Recordsets, RDO Resultsets, or ADO Recordsets in Visual Basic, then replace the data source used by a report at runtime by calling the SetDataSource method of the report Designer object model’s Report object.

The Report Designer Component also provides the ability to design reports based on Data Definition files, text files that define the fields and field types of a database without actually serving as a source of data. Using Data Definition files, you can design a report without depending on the existence of a database at design time, then dynamically create the data at runtime and assign it to the Report object of the Report Designer Component.

If you have installed the full Seagate Crystal Reports product, you also have the ability to use the Report Designer Component to connect to any data source that Seagate Crystal Reports can connect to. In such a case, the Report Designer Component implements the Seagate Crystal Reports user interface that you are already familiar with, so you can quickly connect to any existing data.

Finally, the Report Designer Component also supports Data Environments in Visual Studio 6.0. If your project includes a data environment, the Report Designer Component will allow you to select the data environment as a data source at design time. Runtime reports make full use of the data exposed by a data environment by working with the standard connection, command, or recordset objects provided, much like working directly with an ADO object.

For complete information on data access, refer to Working with data, Page 158.

No drag and drop between reports – use copy and paste

When you have multiple Report Designer Components open within the Visual Basic IDE, you cannot drag and drop objects, such as fields, text objects, subreports, lines and boxes, and formulas between reports. To move or copy objects between reports, use the standard Windows Cut, Copy, and Paste commands.

Conditional Formatting

Conditional formatting is created using formulas. With the Report Designer Component, you can produce conditional formatting results using all of the power of the Visual Basic language. If you have used Seagate Crystal Reports before, you may already be familiar with conditional formatting and the Seagate Crystal Reports formula language. The formula language is still available within the Report Designer Component, but you also have the option of making full use of the entire Visual Basic programming language. For more information on using Visual Basic to produce conditional formatting, refer to Designing Reports in the Visual Basic Integrated Development Environment.

The Report Designer Component

148

Preview Window

Unlike Seagate Crystal Reports, the Report Designer Component does not have a Preview window or tab. Although you can use the methods of the Report object in the Report Designer object model to print or export a report, you must use the Seagate Crystal Smart Viewer for ActiveX to display reports on screen. The Smart Viewer is a standard ActiveX control that can be placed inside any development environment that supports ActiveX controls.

By passing in a Report object created using the Report Designer Component or its object model, you can easily display a report at runtime inside the Smart Viewer. The Smart Viewer window provides several controls and features that allow users to easily navigate and work with your reports. Additionally, the Smart Viewer, as an ActiveX control, can be programmed to create custom features and functionality specific to your application.

For complete information on using the Seagate Crystal Smart Viewer ActiveX control in a Visual Basic application, see Smart Viewer Object Model Programming.

Pictures

Images can now be dynamically displayed in a report at runtime using OLE objects. You may need to display images of products, corporate logos, employee pictures, or any other type of image in your report, but you may want to control which images are displayed based on variables that exist in your application only at runtime.

By adding OLE objects to your report, then changing the image at runtime using the FormattedImage property of the OLE object in the Report Designer object model, you can produce exciting, visually attractive reports for your users. For complete information working with OLE images, see Changing OLE object images.

Guidelines

Guidelines are not implemented in the Report Designer Component’s design window as they are in the Seagate Crystal Reports Design Tab. However, new alignment and sizing options have been added to eliminate much of the need for guidelines.

Subreports

Subreports are supported by the Report Designer Component, but they must be designed from within the main report. In Seagate Crystal Reports, you are able to create subreports from within the main report. You are also able to import existing report files as subreports. With the Report Designer Component, however, you are better off to create your subreports within the main report if you include Visual Basic code in your subreport.

If you create a report in the Report Designer Component and use Visual Basic code in the report, any report calculations or formatting that you performed using that code are dependent on that code being in place. If you save such a report to a Crystal Report file (.rpt), you will lose all the embedded Visual

The Report Designer Component

149

Basic code; the .rpt file format does not support it. (For more information, see Report Distribution Considerations.) If you later insert that report as a subreport using the Report Designer Component, the subreport will not perform as expected.

If you create a subreport from within a main report in the Report Designer Component, all of the Visual Basic code used in the subreport will be stored as part of the executable. Thus, when you run the report, the subreport will perform as it should.

If you want to insert an existing report as a subreport in the Report Designer Component, make certain that you have used the Seagate Crystal Reports formula language for any calculations or conditional formatting in that report.

The dual formula environment

The Report Designer Component supports all of the same formula design capabilities that exist in Seagate Crystal Reports, including the complete Seagate Crystal Reports formula language. However, the Seagate Crystal Report Designer Component, as an ActiveX designer for use inside Visual Basic, also supports the Visual Basic language. By exposing much of its functionality through the Report Designer object model, the Report Designer Component allows you to create powerful functions and procedures that control not only the look of a report, but also the results displayed in a report. With this capability, you are able to leverage your experience with Visual Basic to do more sophisticated reporting. You’ll have:

access to the robust functionality of Visual Basic,

a familiar programming environment, and

no need to learn an additional scripting language.

While you will still be able to use the Seagate Crystal Reports formula language, you won’t need to use it for your calculations and conversions.

On a high level, the way you create calculated fields in the Report Designer using Visual Basic is to:

create a text object,

enter the text object where you want the calculated value to appear,

create a variable to capture the result of the Visual Basic calculation, and

code the calculation.

Finally, you have the text object display the value in the variable via the SetText method.

You can also use Visual Basic code when implementing the Format event procedure of a section in the report. You can open a Format event procedure for a section by double-clicking the section in the Report Designer window or selecting the section and clicking the View Code button in the Visual Basic Project window.

The Report Designer Component

150

Соседние файлы в папке crystal