我正在尝试设计一组包含自己的数据库访问的数据控件。
因此,我创建了一个 TDataSource 后代,它具有附加属性,可以将其自身附加到数据库并创建数据集等...
如果我将其附加到 DBLookupComboBox 作为 ListSource 一切都很好。但是,如果我尝试创建此数据源作为 DBLookupComboBox 的子组件并将其指定为 ListSource,我会达到似乎 第 22 条军规。
我希望 DataSource 的属性与 DBLookupComboBox 一起进行流式传输,并且希望将 DBLookupComboBox 的 ListSource 设置为 DataSource 子组件,但我似乎无法同时执行这两个操作。当 DBLookupComboBox 进行流式传输时,DataSource 的附加属性将被包含两次,一次(正确地)在 DataSource 属性本身下,一次在 ListSource.Property1 下,最后一次将导致“无效的属性路径” > 当组件加载时,即使数据源是预先创建的(并注册等)。
如果 TDataSource 是子组件,只要它设置了一些非默认属性(即标签),也会发生同样的情况。
我尝试设计一个存储函数,允许 DataSource 属性进行流式传输,但不允许 ListSource 属性进行流式传输,但没有成功。
对于如何开展这项工作的任何帮助或指导,我将不胜感激。
DFM(片段)看起来像
object PmDCB1: TPmDCB
Left = 384
Top = 160
Width = 145
Height = 24
ListSource.Tag = 222
TabOrder = 0
ViewName = 'VAR'
WindowName = 'WNE'
View.Tag = 222
end
I am trying to design a set of data controls that contain their own database access.
So I create a TDataSource descendant which has additional properties and can attach itself to the database and create datasets etc...
If I attach this to a DBLookupComboBox as the ListSource all is well. However if I try to create this Datasource as a subcomponent of the DBLookupComboBox and specify it as the ListSource, I reach what seems a catch-22.
I wish the properties of the DataSource to be streamed with the DBLookupComboBox, and I wish the ListSource of the DBLookupComboBox to be set to the DataSource subcomponent but I cannot seem do both. When the DBLookupComboBox is streamed, the additional properties of the DataSource will be included twice, once (correctly) under the DataSource property itself, and once under ListSource.Property1 and this last will cause an “Invalid property path” when the component is loaded, even if the DataSource is created up front (and registered etc).
The same thing happens if a TDataSource is the subcomponent as long as it has some non default property (ie Tag) set.
I have tried to devise a Stored Function that would allow the DataSource properties to stream but not the ListSource properties without success.
I would be grateful for any help or direction on how to make this work.
The DFM (fragment) looks like
object PmDCB1: TPmDCB
Left = 384
Top = 160
Width = 145
Height = 24
ListSource.Tag = 222
TabOrder = 0
ViewName = 'VAR'
WindowName = 'WNE'
View.Tag = 222
end
发布评论
评论(2)
好的 - 最终找到了一个有效的答案 - 覆盖 DBLookupComboBox 的 WriteState 过程并将 ListSource 设置为 nil,然后调用继承,然后再次设置 ListSource。
不太难看,这是我能找到的唯一能在一周的挖掘中起作用的东西。
OK - eventually found an answer that works - Override the DBLookupComboBox's WriteState procedure and set the ListSource to nil, then call inherited, then set ListSource back again.
Not too ugly and its the only thing i could find that works in a week of digging.
您是否尝试过类似以下的操作?
Have you tried something like the following?