The following are the simplest functions of each control. Other functions are described based on the specific implementation.
1. TquickRep: a container with coordinates. As a container of other report controls (such as TQRBand), its Band attribute can automatically add various types of TQRBand.
2. TQRLabel: Print static text (that is, it is not changed based on the database value). The content of the content like Tlabel and Caption is printed.
3. TQRDBText: print the database field value, one value row. Role: TDBText. assign its DataSet and DataField to Table1 respectively. When Company, the content of the Company field of the table pointed to by Table1 is printed.
4. TQRSysData: prints system information such as time, page number, and report class.
5. TQRMemo: it is very similar to TQRLabel, but it can print multiple rows and also print static data.
6. TQRRichText: print the RichText format. It can connect to the RichEdit control on a Form and print its content, but it must be a 32-bit version.
7. TQRShape: Print box, circle, vertical, and horizontal line.
8. TQRImage: Print static images, including (BMP, WMF, ICON ).
9. TQRDBImage: receives images from the database.
10. TQRBand: used to determine what content should be displayed in different positions of the Report. controls can be placed on it (see section 2 ).
11. TQRGoups: Groups can be used for group operations at any level. When you connect several datasets to a report, you can operate dataset in Groups through Groups.
2. Control placement of reports in sequence
PageHeader)
|
Title (only available on the home page)
|
Title of all columns (ColumnHeader)
|
Record Content, one field and one column (Detail)
|
Summary (available on the last page)
|
PageFooter)
These are located based on the different Band settings (not a control, but a type, and other controls can be placed on it. There are a total of six bands.
3. A simple example
In this example, a report is created to print part of the field name and the field data content of a table.
1. Create a new project
2. Put a TTable on Form, set DatabaseName to BCDEMOS, TableName to point to the Customer table, and Active to true.
3. Place a TquickRep control on the Form, and set the DataSet attribute to Table1. (that is, to display the table pointed to by Table1 above ).
4. expand the Bands attribute of TquickRep and set HasDetail to true. At this time, a detail band (A TQRBand control) is automatically added, so you can also directly put a TQRBand control, set the BandType attribute to detail ).
5. Place a TQRDBText control on the detail band, set DataSet to Table1, and DataField to Company. Step 4 is to set where the report displays the data type, while TQRDBText is implemented.
6. Select the TquickRep control, right-click, and select "Preview" to Preview. All the Field Values of the Company field in the Customer table should be displayed.
In this simple example, it is OK. to preview the program and use the print function provided by TQRuickRep, you only need to add a button in Form. Its OnClick event is: quickRep1-> Preview ();
4. A report using the TQRGoups and TQRExpr controls
This report first lists the State names, then the total number of all the companies and companies in the state. After a State column is completed, a blank row (groups interrupted) is displayed to list the new State names, then, all the companies in the new state are listed under the Unknown state.
1. Create a new project.
2. put a Tquery on Tquickrep. The SQL attribute is select * from customer order by State, Company; (sort by State or Company), DatabaseName is BCDMome, and Active is true.
3. Put a TquickRep control on Form1, and DataSet is Tquery1.
4. Place a TQRGroups control on TquickRep. The default value is the group header. (When a group is interrupted or a group is interrupted at a higher level, this header is printed. If an expression exists, the content is displayed based on the value of the expression .) Add a group footer band. When the Group Footer band is added, place a TQRBand control in the report and connect the FooterBand attribute of the TQRGroups to the QRBand. Then the new TQRBand becomes the group footer. (an important feature of TQRGroup is the expression. When the expression value changes, the Group will be interrupted. For example, the expression lists city names by province and Guangdong currently, when the expression value changes after the city column in the province, the Group is interrupted and the city name in other provinces is displayed .) The expression_r attribute of TQRGroups is set to Query1.State (interrupted based on different States ).
5. Place a TQRBand control on the report. The BandType is rbDetail.
6. put a TQRExpr control on the group header, and its expression_r attribute is: if (State <> '', State, 'unknown state'), that is, if the company's state is not filled, it is classified into the Unknown state, otherwise it is classified into the State.
7. put three TQRDBText on Detail. Their DataSet points to Query1, and DataField points to Company, Contact, and Phone respectively.
8. put a TQRExpr control on the group Footer. The expression_r value is 'customer' + State + ':' + Str (Count) the role is to show the total number of companies in each state after listing them.
9. Right-click and select preview. You can see the names of different States and their total number of companies and companies.
V. Quick report conditional Printing
You can specify the condition judgment directly in the OnFilter event of TQuickReport. There is a PrintRecord-type variable declared in var in the OnFilter event, and this variable is set to True (default value ), this record will be printed; otherwise, it will not be printed if it is set to False.
Procedure TForm1.QuickReport1Filter (var PrintRecord: Boolean );
Begin
PrintRecord: = False;
If YourTable. FieldByName ('wantedfield'). AsInteger <= 100 then