1

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?

JustMe
  • 2,329
  • 3
  • 23
  • 43

1 Answers1

1

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);
JustMe
  • 2,329
  • 3
  • 23
  • 43
  • 1
    Still can't find where 'FieldName' property editor is registered, though – JustMe Dec 11 '12 at 16:44
  • what you mean by "where 'FieldName' property editor is registered? – jachguate Dec 11 '12 at 16:57
  • 1
    @jachguate - AFAIU it means the answer does not answer the question. – Sertac Akyuz Dec 11 '12 at 17:01
  • 2
    This doesn't answer the question. The question asks *where* the property editor is registered. This answer tells *what* the registration might look like, but there is no such line anywhere in the source code. – Rob Kennedy Dec 11 '12 at 17:49
  • 1
    In Delphi 5 it is registered for TColumn on line 473 of the `dbreg` unit: `RegisterPropertyEditor(TypeInfo(string), TColumn, 'FieldName', TColumnDataFieldProperty);` – Marjan Venema Dec 11 '12 at 18:33
  • @Marjan - You've got it, it's in vcldbreg.pas in newer versions. – Sertac Akyuz Dec 11 '12 at 19:12
  • @MarjanVenema My delphi 7 `dbreg` it's only 411 lines long and it's not containig such line :( – JustMe Dec 12 '12 at 07:15
  • Most probably it is in a different unit. Sertac has already given you a hint where it lives in newer versions. If it isn't there, use your favorite grep utility and look for all RegisterPropertyEditor lines until you find it... That's how I found it in D5. – Marjan Venema Dec 12 '12 at 07:18
  • @MarjanVenema I've greped all disc but I haven't found `TColumn` registering a property editor (and I've got only `TDataFieldProperty` but not `TColumnDataFieldProperty`) - it just bothering me so much – JustMe Dec 12 '12 at 07:31
  • Well, that's unfortunate, but it has to be there somewhere or it wouldn't work. Though of course the IDE doesn't use the source directly. Do hope you didn't (inadvertently) change the vcl sources... I am sorry but I can't help you further, don't have D7 and can't look on your hard disk. – Marjan Venema Dec 12 '12 at 07:44
  • Just - The source is missing, also in D2007. That's why we failed to locate it. It was only after @Marjan mentioned TColumnDataFieldProperty I gave it another chance with other versions, f.i. XE and XE2 have it. There's not much you can do about it, the vendor will not fix it. – Sertac Akyuz Dec 12 '12 at 23:21
  • @SertacAkyuz Yea you're right - I've greped it in dcldb.bpl file but can't find it in pas file. Thank you for clarifying :) – JustMe Dec 13 '12 at 08:55