I want to add two properties to my component: a TDataSet and a TField, so that when I set the TDataset property I can then select from its fields in the DataField Property.
I don't know how to make the relation between the DataField and the DataSet properties.
How can I do that?
If you change your component to have a DataSource: TDataSource
property instead of a DataSet: TDataSet
property, Delphi's standard TDataFieldProperty
editor will automatically populate your DataField: string
property for you. You can then link your desired TDataSet
component to a TDataSource
component.
If you want the drop-down list to appear for any string
property that is not named DataField
, you can register TDataFieldProperty
manually for that property via RegisterPropertyEditor()
.
If you want to have a TDataSource
property whose name is not DataSource
, you can derive from TDataFieldProperty
and override its virtual GetDataSourcePropName()
method.
If you must accept a TDataSet
directly, you will have to write a custom property editor for your DataField
property, and have it call TDataSet.GetFieldNames()
directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.