System.Classes.TDataModule

From RAD Studio API Documentation
Jump to: navigation, search

System.Classes.TComponentSystem.Classes.TPersistentSystem.TObjectTDataModule

Delphi

TDataModule = class(TComponent)

C++

class PASCALIMPLEMENTATION TDataModule : public TComponent

Properties

Type Visibility Source Unit Parent
class public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Description

TDataModule centralizes the handling of nonvisual components in an application.

Use a TDataModule object in an application to provide a location for centralized handling of nonvisual components. Typically these are data access components, such as TSQLDataSet, and TSQLConnection. DataModules are not limited to data access components, they can also contain other nonvisual components, such as TTimer, TOpenDialog, or TImageList.

At design time, a TDataModule object provides a visual container into which you can place nonvisual components, set their properties, and write event handlers for them. To create a data module at design time, from an existing application choose:

  • File > New > Other > personality Files > Data Module

where personality is either Delpi or C++Builder.

In the unit file for the data module, you can also place any business rules that are to be applied to the application.

To make the data module available to another unit in the application, select the unit, then choose either:

  • File > Use Unit (when working in Delphi)
  • File > Include Unit Header (when working in C++)

This adds the data module to the uses clause for the unit.

Note: Data modules are framework-neutral at the XE2 release; that is, you start with the same basic data module for any framework. TDataModule has a pseudo-property ClassGroup that enables you to specify the associated framework to be used with the data module. This is critical for nonvisual framework-specific components. The ClassGroup pseudo-property controls which framework-specific nonvisual components are available in the Tool Palette.



For example, the VCL nonvisual component TActionList does not appear in the Tool Palette for a data module whose ClassGroup pseudo-property is System.Classes.TPersistent (framework-neutral) rather than Vcl.Controls.TControl (framework-specific). For more information, see the ClassGroup pseudo-property of TDataModule.

The ClassGroup pseudo-property is used only by the IDE and indicates the data module's relationship with a particular component framework, if any. Then the IDE enforces the kinds of components that you can drop on the data module.


See Also