TColumn.FieldName property editor

718 Views Asked by At

I'm analyzing the DBGrids.pas unit. There's a TColumn class which have published the FieldName property

property  FieldName: String read FFieldName write SetFieldName;

It's declared as a string but in the object inspector it's appear as a editable combobox (TDataFieldProperty)

I analyzed almost all DBGrids unit and can't find place where that trick is done. Where should I look?

1

There are 1 best solutions below

12
On

What you're looking for - dear past me - is the RegisterPropertyEditor method.

Call RegisterPropertyEditor to associate the property editor class specified by the EditorClass parameter with the property type specified by the PropertyType parameter.

In your case you need a TDataFieldProperty so it will be like:

RegisterPropertyEditor(TypeInfo(string), TColumn, 'FieldName', TDataFieldProperty);