Creating and Editing Standard Data Modules

From RAD Studio
Jump to: navigation, search

Go Up to Using Data Modules

To create a standard data module for a project, choose:

  • File > New > Other > Delphi Projects > Delphi Files > Data Module
  • File > New > Other > C++Builder Projects > C++Builder Files > Data Module

The IDE opens a data module container on the desktop, displays the unit file for the new module in the Form Designer, and adds the module to the current project.

At design time, a data module looks like a standard form with a white background and no alignment grid. As with forms, you can place nonvisual components from the Tool Palette onto a module, and edit their properties in the Object Inspector. You can resize a data module to accommodate the components you add to it.

Setting the Framework Affinity for a Data Module

Standard data modules are platform-neutral. If you want to use a data module with a specific platform (such as VCL, or FMX OS X), you need to set the platform affinity for your data module. TDataModule supports the ClassGroup pseudo-property for this purpose. Specifically, ClassGroup controls the nonvisual components that are available in the Tool Palette. This also means that you need to compile platform-specific versions of all your data modules that are to be available on any of the Supported Target Platforms.

When you set the ClassGroup for a data module, you can choose from the following options:

  • System.Classes.TPersistent (Default, Platform-Neutral)
  • VCL (Windows)
  • FMX (Windows or multi-device)

For more information, see Setting the Framework Affinity for a Data Module.

Context Menu for Data Modules

Right-click a module to display its context menu.

The following table summarizes the context menu options for a data module:


Menu item Purpose
Edit Displays a context menu with which you can cut, copy, paste, delete, and select the components in the data module.
Position Aligns nonvisual components to the invisible grid of the module (Align To Grid) or according to criteria you supply in the Alignment dialog box (Align).
Tab Order Enables you to change the order that the focus jumps from component to component when you press the tab key.
Creation Order Enables you to change the order that data access components are created at start-up.
Revert to Inherited Discards changes made to a module inherited from another module in the Object Repository, and reverts to the originally inherited module.
Add to Repository Stores a link to the data module in the Object Repository.
View as Text Displays the text representation of the properties of the data module.
Text DFM Toggles between the formats (binary or text) in which this particular form file is saved.

Topics

See Also