在 delphi 中创建时从数据库填充单选框
populating radio group box from database at creation in delphi
在 Delphi 7 中,我创建了一个无线电组组件,其项目是从数据库 table 中获取的。使用的 table 表示为组件属性之一。 populate() 过程在运行时调用时成功地填充了组。但是我想在创建时填充组,当我尝试引用 tablename 属性(通过 getTableName())时,即使在构造函数方法的末尾,它也是空的。我怎样才能做到这一点?什么时候填充私有变量 fTablename?
when I try to reference the tablename property (through getTableName()) even at the end the constructor method, it is empty.
这是因为设计时 属性 值在构造期间尚未从 DFM 流式传输到组件中。那是在施工完成后发生的。
How can I do this? At what point does the private variable fTablename get populated?
当其 属性 被分配时,例如在 DFM 流式传输期间。
如果您想在 运行 时对设计时值进行操作,您需要覆盖虚拟 Loaded()
方法,该方法在 DFM 流式传输到组件后被调用。
此外,任何使用现有 属性 值执行实时更新的 属性 设置器应首先检查 ComponentState
属性 的 csLoading
和csReading
在执行这些更新之前标记。如果设置了标志,则延迟更新直到 Loaded()
被调用。
在 Delphi 7 中,我创建了一个无线电组组件,其项目是从数据库 table 中获取的。使用的 table 表示为组件属性之一。 populate() 过程在运行时调用时成功地填充了组。但是我想在创建时填充组,当我尝试引用 tablename 属性(通过 getTableName())时,即使在构造函数方法的末尾,它也是空的。我怎样才能做到这一点?什么时候填充私有变量 fTablename?
when I try to reference the tablename property (through getTableName()) even at the end the constructor method, it is empty.
这是因为设计时 属性 值在构造期间尚未从 DFM 流式传输到组件中。那是在施工完成后发生的。
How can I do this? At what point does the private variable fTablename get populated?
当其 属性 被分配时,例如在 DFM 流式传输期间。
如果您想在 运行 时对设计时值进行操作,您需要覆盖虚拟 Loaded()
方法,该方法在 DFM 流式传输到组件后被调用。
此外,任何使用现有 属性 值执行实时更新的 属性 设置器应首先检查 ComponentState
属性 的 csLoading
和csReading
在执行这些更新之前标记。如果设置了标志,则延迟更新直到 Loaded()
被调用。