15th chapter-Application and programming of data access Parts (III.) (1)

Source: Internet
Author: User

The field part is always invisible in the application. This is true in the process of program design, but it plays a very important role in the application, it can be said that it is the basis for all data browsing parts to display and edit data from database tables. This is because the field parts correspond directly to the fields in the database tables, and the data in the table must be browsed and modified by the field part, while the properties owned by the field part can be used to describe the data type of the corresponding field in the database table, the current field value, display format, edit format, etc. The event for a field part, such as OnValidate, can be used to set the validation of input field values.

Each column in the database table has a corresponding field part in the application, by default, when the active property of the ttable or Tquery is set to false or when the Close method is called, the field parts corresponding to the columns in the table disappear. To create a permanent field widget for your application, we must create it using the field editor (Fields Editor) in the design phase of the program. The advantage of using the field editor to create permanent fields is that we use permanent field parts in the program code to access the values of the fields that are recorded in the database table more efficiently, conveniently, and reliably, and at any time, we can display the records in the table in the same field order, in a fixed field, Even if the structure of the database table has changed. Of course, if the field that corresponds to the field part in the database table does not already exist, the application will not execute normally, Delphi will pop up an error message box to tell the user that the field in the table no longer exists.

15.6. Properties and applications of 1.1 field components

A field part has many properties that allow you to control how the Field object is displayed in the data navigation part, whether the field values can be modified, and so on, by setting the properties for the field part. Especially for permanent field parts created with the field editor, we can easily select the field parts in the object inspector in the program design phase to set the properties.

The primary properties of the field part, as shown in table 15.6, are the properties listed in the table that are part of the field part, and are used primarily to control how the Field objects are displayed.

Table 15.6 Main properties of field parts

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Property name Feature

───────────────────────────────

Alignment describes how field values are aligned when they are displayed in the data navigation part:

Left aligned, right aligned, centered three ways.

───────────────────────────────

Calculated indicates whether the field is a calculated field and, when the property value is true, the

Fields are calculated fields, field values can be based on other fields in the table

Calculated by the value.

───────────────────────────────

When Currency equals True, the value is displayed in currency format, which is equal to false.

Numeric data is not displayed in currency format.

───────────────────────────────

DisplayFormat is used to describe the format in which field values are displayed in the data browsing part

───────────────────────────────

Displaylabel field when displayed in a grid (Tdbgrid part), specify

Displays the title.

───────────────────────────────

Displaynidth field when displayed in a grid (Tdbgrid part), specify

Display width, in units of characters.

───────────────────────────────

Editformat Description field Edit input format in the data browsing part

───────────────────────────────

Editmask When you edit input for a field value, you qualify the value of the input field.

Filter criteria (that is, the range of field values).

───────────────────────────────

FieldName This field part corresponds to the name of the field in the actual database table

───────────────────────────────

Index The order number of the field part in all field parts of the dataset

───────────────────────────────

MaxValue Description You can enter the maximum number for this field

───────────────────────────────

MinValue Description You can enter a minimum number for this field

───────────────────────────────

Name field part

───────────────────────────────

When ReadOnly equals True, only the field values of the field can be read and cannot be modified;

is equal to False, you can read and write the field values for the field.

───────────────────────────────

Size Description field sizes, in units of characters

───────────────────────────────

When Visible is true, the field can be displayed in the Tbdbgrid part;

False, the field cannot be displayed in the Tdbgrid part

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.