How to Create a DB component with FIELD selector

Hi, I want to create a DB component where I select the Datasource. That works correctly, but when I want to select the FIELD (TFIELD) I get a list of ALL fields. I only want to have the fields from the source I've selected in the object inspector.

Anyone knows How?
AvatarisAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
TOndrejConnect With a Mentor Commented:
Have a look in DBReg unit...

RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TDataFieldProperty);

This means that TDataFieldProperty property editor is registered for all string properties called 'DataField' of all TComponent descendants.

I guess your component is a TComponent descendant <g>.
Is your property of type string?
Is it called 'DataField'?

IOW, does the declaration look similar to the following:

property DataField: string read GetDataField write SetDataField;

??

Please be more specific, and show us how the property is declared and any other info you think might be useful.
From the symptoms you describe it seems that your property is of type TField... but I don't want to guess for no good reason.

TOndrej
0
 
AvatarisAuthor Commented:
Yes the property is declared like that, I want to have a combobox with the fields from the table in the property editor.
0
 
AvatarisAuthor Commented:
I don't have a DBREG anything :(
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
TOndrejCommented:
Please show me the exact declaration and get/set methods and the internal field declaration.
0
 
AvatarisAuthor Commented:
But I think i get your point :)
I'll test it now.
0
 
TOndrejCommented:
I have it in <delphidir>\Source\Property Editors\dbreg.pas
(Delphi 5 Enterprise)
0
 
AvatarisAuthor Commented:
Thanx, this method :

RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TDataFieldProperty);


Is all I needed :)
0
 
TOndrejCommented:
It's strange that you needed it.

Anyway... You don't seem to be interested in a complete solution. Good luck.
0
 
AvatarisAuthor Commented:
Thanx, this method :

RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TDataFieldProperty);


Is all I needed :)
0
 
AvatarisAuthor Commented:
I don't have Delphi 5, just Delphi 4.
Delphi 4 has no examples about the subject.
Complete solutions take the fun of programming away ;)

But my component works fine now :)
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.