加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi XE2数据模块只需要数据库组件?

发布时间:2020-12-15 10:16:42 所属栏目:大数据 来源:网络整理
导读:在以前的Delphi版本中,我已经使用数据模块(TDataModule)作为一个地方来保持非可视化组件,以避免混乱主窗体。在Delphi XE2中,当我创建一个新的数据模块时,它只允许我在数据库中放置数据库相关的组件(如TADOConnection和TDataSource)。为什么会这样,我该
在以前的Delphi版本中,我已经使用数据模块(TDataModule)作为一个地方来保持非可视化组件,以避免混乱主窗体。在Delphi XE2中,当我创建一个新的数据模块时,它只允许我在数据库中放置数据库相关的组件(如TADOConnection和TDataSource)。为什么会这样,我该怎么把其他组件放在其中?有办法吗

解决方法

数据模块随XE2版本而改变。记住,XE2除了长期存在的VCL之外,还引入了一个新的组件框架FireMonkey。一个新的伪属性,名为 ClassGroup被添加到数据模块。这将控制哪些组件可以添加到IDE设计器中的数据模块中。

数据模块的默认值为ClassGroup为System.Classes.TPersistent。这指定数据模块是框架中性的,因此不接受VCL组件或FMX组件。

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

阅读documentation中有关ClassGroup的全部信息。

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

  • Determines the framework affinity for the data module. That is,ClassGroup specifies that the data module is either framework-neutral
    or is to work with a specific framework (namely,VCL or FMX).
  • Enables framework-specific nonvisual components in the Tool Palette. You need to set a framework-specific value for ClassGroup in
    the Object Inspector in order to enable framework-specific nonvisual
    components such as the following:
    • TActionList is VCL-only,and so to enable TActionList in the Tool Palette,you must set ClassGroup to the VCL setting.
    • TTimer exists in both FMX and VCL. To enable TTimer for the correct framework,you must set ClassGroup to either FMX or VCL,to match the framework of the parent application. (TTimer and TActionList are further discussed later in this topic.)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读