Delphi XE2数据模块仅需要数据库组件? [英] Delphi XE2 Data Module expects only database components?

查看:142
本文介绍了Delphi XE2数据模块仅需要数据库组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以前的Delphi版本中,我使用数据模块( TDataModule )作为保留非可视组件的地方,以避免使主表单混乱。在Delphi XE2中,当我创建一个新的数据模块时,它只允许我在其中放置数据库相关的组件(例如 TADOConnection TDataSource )。为什么会这样,如何将其他组件放入其中?有替代方法吗?

In prior versions of Delp I have used the data module (TDataModule) as a place to keep non-visual components to avoid cluttering up the main form. In Delphi XE2, when I create a new data module, it only allows me to place database related components in it (such as TADOConnection and TDataSource). Why is this and how can I put other components in it? Is there an alternative?

推荐答案

数据模块随XE2发行版而更改。请记住,XE2除了长期使用的VCL之外,还引入了新的组件框架FireMonkey。一个名为 ClassGroup 已添加到数据模块。这控制可以在IDE设计器中将哪些组件添加到数据模块。

Data modules changed with the XE2 release. Remember that XE2 introduced a new component framework, FireMonkey, in addition to the long-standing VCL. A new pseudo-property, named ClassGroup was added to data modules. This controls what components can be added to the data module in the IDE designer.

默认 ClassGroup System.Classes.TPersistent 。这指定数据模块是框架无关的,因此既不接受VCL组件也不接受FMX组件。

The default ClassGroup for a data module is System.Classes.TPersistent. This specifies that the data module is framework neutral and so accepts neither VCL components nor FMX components.

在您的情况下,您可能希望接受VCL组件,因此需要指定一个 ClassGroup of Vcl.Controls.TControl

In your case you probably want to accept VCL components so you need to specify a ClassGroup of Vcl.Controls.TControl.

读取文档中有关 ClassGroup 的全部内容。

Read all about ClassGroup in the documentation.


System.Classes.TDataModule及其子类(例如
Web.HTTPApp.TWebModule)具有名为
执行以下操作的ClassGroup:

System.Classes.TDataModule and its descendant classes, such as Web.HTTPApp.TWebModule, have a pseudo-property named ClassGroup that does the following:


  • 确定与数据模块的框架相似性。也就是说,ClassGroup指定数据模块是与框架无关的
    或与特定框架(即VCL或FMX)一起使用。

  • 启用特定于框架的非可视化工具面板中的组件。您需要在
    对象检查器中为ClassGroup设置特定于框架的值,以启用特定于框架的非可视
    组件,例如:

    • TActionList仅限于VCL,因此要在工具面板中启用TActionList,必须将ClassGroup设置为VCL设置。

    • TTimer在FMX和VCL中都存在。要为正确的框架启用TTimer,必须将ClassGroup设置为FMX或VCL,与父应用程序的框架匹配的
      。 (TTimer和TActionList
      将在本主题的后面进一步讨论。)

    这篇关于Delphi XE2数据模块仅需要数据库组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆