Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

Defining a calculated field

Читайте также:
  1. A. Defining Interpersonal Communication
  2. After Katherine Mansfield
  3. Chapters 11-26: Jane's time as governess at Thornfield Hall
  4. Choose and describe control method for the field.
  5. Chronological resume template (pipe line and oil field construction specialist)
  6. Close-Field Monitoring
  7. Coursework 13: Electric and Gravitational Forces and Fields

A calculated field is used to display values calculated at run time in the dataset’s OnCalcFields event handler. For example, you might create a string field that displaysconcatenated values from two other fields.

To create a calculated field:

1 Choose the Define button in the Fields Editor window.

2 Enter the name of the new field in the Field Name edit box, or select a field name from the drop-down list. A corresponding TField component name appears automatically in the Component edit box as you type. This name is the identifier you use to access the field programmatically.

3 Select the data type for the field from the Field Type list box.

4 Check the Calculated check box if it is not already checked.

5 Choose OK. The newly defined calculated field is automatically added to the Fields list box in the main Fields Editor window, and the component declaration is automatically added to the form’s type declaration in the source code.

To edit the properties or events associated with the new TField component, select the component name in the Fields list box, then edit the properties or events via the Object Inspector.

 

Programming a calculated field

Once a calculated field is defined, it has a null value unless you write code to provide values for the field. Code for a calculated field is placed in the OnCalcFields event for its dataset. An OnCalcFields event handler can only modify fields that have a Calculated property of True.

For example, on Form1, the OnCalcFields event for a TTable component named Table1 is

TForm1.Table1CalcFields

To program a value for a calculated field:

1 Select the TTable or TQuery component from the Object Inspector drop-down list.

2 Choose the Object Inspector Events tab.

3 Double-click the OnCalcFields property to bring up or create a CalcFields procedure for the TTable or TQuery component.

4 Write the code that sets the values and other properties of the calculated field as desired.

 

Editing a TField component

You can customize properties and events of persistent TField components at design time. To do this, select the TField either in the Fields list box of the Fields Editor or the component list of the Object Inspector. Properties control the way a field is displayed by a data-aware component, for example, whether it can appear in a TDBGrid, or whether its value can be modified. Events control what happens when data in a field is fetched, changed, set, or validated.

 


Дата добавления: 2015-10-23; просмотров: 154 | Нарушение авторских прав


Читайте в этой же книге: Lecture 9. Using Data Controls | Searching a table | Using TDataSource events |
<== предыдущая страница | следующая страница ==>
Using TFields and the Fields Editor| KRS 0000234069, Regon 300055546, NIP 6080024482

mybiblioteka.su - 2015-2024 год. (0.005 сек.)